summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2019-05-01 06:11:47 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2019-05-01 06:11:47 +0000
commit04a31e5424c73b06d2df33edcb0a32b8853ba888 (patch)
tree3a6e777c95392563fa2fe2fd76ac1220426954d2 /sys/net
parent8eb1c80ffa1f2bec2c977b5d6d4847c8a85f0aba (diff)
pretty much all of tun_wakeup needs to be protected with KERNEL_LOCK
tun_wakeup is called from the network stack, which generally runs with NET_LOCK, not KERNEL_LOCK, which is a problem when it calls into things like csignal or kq code. this started causing corruption and panics of a list inside the kq code, which got reported to bugs@. this version of the fix is ok mpi@ (even though he hasn't seen it) an earlier but far trickier fix was ok visa@ the bug was reported by Olivier Antoine, and again by jmc@ privately.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_tun.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index b8b0146bd6c..ac45bbac016 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.184 2019/02/03 23:04:49 dlg Exp $ */
+/* $OpenBSD: if_tun.c,v 1.185 2019/05/01 06:11:46 dlg Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -583,6 +583,7 @@ tun_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
void
tun_wakeup(struct tun_softc *tp)
{
+ KERNEL_LOCK();
if (tp->tun_flags & TUN_RWAIT) {
tp->tun_flags &= ~TUN_RWAIT;
wakeup((caddr_t)tp);
@@ -591,6 +592,7 @@ tun_wakeup(struct tun_softc *tp)
csignal(tp->tun_pgid, SIGIO,
tp->tun_siguid, tp->tun_sigeuid);
selwakeup(&tp->tun_rsel);
+ KERNEL_UNLOCK();
}
/*