summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2017-08-22 15:02:34 +0000
committermpi <mpi@openbsd.org>2017-08-22 15:02:34 +0000
commited223d74f4ec983eb51a90d2d42d93a2f4241055 (patch)
treedbc66672ffe1b9d944c9c67272b8e6086ffded74 /sys/netinet6
parentsync (diff)
downloadwireguard-openbsd-ed223d74f4ec983eb51a90d2d42d93a2f4241055.tar.xz
wireguard-openbsd-ed223d74f4ec983eb51a90d2d42d93a2f4241055.zip
Prevent a race against ipsec_in_use.
Problem reported and fix tested by Hrvoje Popovski. ok bluhm@, visa@
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/ip6_input.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index db87b569dc0..ade41a8a03b 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_input.c,v 1.201 2017/08/11 21:24:20 mpi Exp $ */
+/* $OpenBSD: ip6_input.c,v 1.202 2017/08/22 15:02:34 mpi Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -1450,6 +1450,8 @@ ip6_send_dispatch(void *xmq)
if (ml_empty(&ml))
return;
+ NET_LOCK();
+
#ifdef IPSEC
/*
* IPsec is not ready to run without KERNEL_LOCK(). So all
@@ -1458,12 +1460,13 @@ ip6_send_dispatch(void *xmq)
*/
extern int ipsec_in_use;
if (ipsec_in_use) {
+ NET_UNLOCK();
KERNEL_LOCK();
+ NET_LOCK();
locked = 1;
}
#endif /* IPSEC */
- NET_LOCK();
while ((m = ml_dequeue(&ml)) != NULL) {
ip6_output(m, NULL, NULL, IPV6_MINMTU, NULL, NULL);
}