diff options
author | mpi <mpi@openbsd.org> | 2020-04-11 10:49:27 +0000 |
---|---|---|
committer | mpi <mpi@openbsd.org> | 2020-04-11 10:49:27 +0000 |
commit | 5e128c65a47fa2b3145a84ab541a7889c3302fac (patch) | |
tree | a4085ac1bb3f0e931e3a7f26dfce18d27919b70c /sys/net/if.c | |
parent | fix build with PFSYNC_DEBUG by switching a format string from %d to %zd (diff) | |
download | wireguard-openbsd-5e128c65a47fa2b3145a84ab541a7889c3302fac.tar.xz wireguard-openbsd-5e128c65a47fa2b3145a84ab541a7889c3302fac.zip |
Grab the exclusive NET_LOCK() in the softnet thread.
Prevent a data corruption on a UDP receive socket buffer reported by
procter@ who triggered it with wireguard-go.
The symptoms are underflow of sb_cc/sb_datacc/sb_mcnt.
ok visa@
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 74bac22cdc2..7b62c1c21d9 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.601 2020/03/10 09:11:55 tobhe Exp $ */ +/* $OpenBSD: if.c,v 1.602 2020/04/11 10:49:27 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -938,10 +938,10 @@ if_input_process(struct ifnet *ifp, struct mbuf_list *ml) * to PF globals, pipex globals, unicast and multicast addresses * lists. */ - NET_RLOCK(); + NET_LOCK(); while ((m = ml_dequeue(ml)) != NULL) if_ih_input(ifp, m); - NET_RUNLOCK(); + NET_UNLOCK(); } void @@ -975,14 +975,14 @@ if_netisr(void *unused) { int n, t = 0; - NET_RLOCK(); + NET_LOCK(); while ((n = netisr) != 0) { /* Like sched_pause() but with a rwlock dance. */ if (curcpu()->ci_schedstate.spc_schedflags & SPCF_SHOULDYIELD) { - NET_RUNLOCK(); + NET_UNLOCK(); yield(); - NET_RLOCK(); + NET_LOCK(); } atomic_clearbits_int(&netisr, n); @@ -1037,7 +1037,7 @@ if_netisr(void *unused) } #endif - NET_RUNLOCK(); + NET_UNLOCK(); } void |