diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2017-08-22 15:02:35 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2017-08-22 15:02:35 +0000 |
commit | 7e0072c4beaa10376f11763a114c7c20c013f6c3 (patch) | |
tree | f4173a53bfbc9382658e2f86ac8740557fcf1a03 /sys/netinet/ip_input.c | |
parent | 33d6e799aa964c49fab45699f4f9a5cdba2a8ed7 (diff) |
Prevent a race against ipsec_in_use.
Problem reported and fix tested by Hrvoje Popovski.
ok bluhm@, visa@
Diffstat (limited to 'sys/netinet/ip_input.c')
-rw-r--r-- | sys/netinet/ip_input.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 67f2f27d749..b7fd4dde46d 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.318 2017/08/11 21:24:20 mpi Exp $ */ +/* $OpenBSD: ip_input.c,v 1.319 2017/08/22 15:02:34 mpi Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -1802,6 +1802,8 @@ ip_send_dispatch(void *xmq) if (ml_empty(&ml)) return; + NET_LOCK(); + #ifdef IPSEC /* * IPsec is not ready to run without KERNEL_LOCK(). So all @@ -1810,12 +1812,13 @@ ip_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) { ip_output(m, NULL, NULL, 0, NULL, NULL, 0); } |