summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2020-04-12 06:59:54 +0000
committerdlg <dlg@openbsd.org>2020-04-12 06:59:54 +0000
commit422f84d95df9c53dcc980c3d0201aedeba0879a8 (patch)
tree6500a72d477ed21e41b23a3f034b7b1c5ea105e6 /sys/net
parenttake NET_LOCK in tpmr_clone_destroy() before calling tpmr_p_dtor() (diff)
downloadwireguard-openbsd-422f84d95df9c53dcc980c3d0201aedeba0879a8.tar.xz
wireguard-openbsd-422f84d95df9c53dcc980c3d0201aedeba0879a8.zip
take NET_LOCK in aggr_clone_destroy() before calling aggr_p_dtor()
aggr_p_dtor() calls ifpromisc(), and ifpromisc() callers need to be holding NET_LOCK to make changes to if_flags and if_pcount, and before calling the interfaces ioctl to apply the flag change. i found this while reading code with my eyes, and was able to trigger the NET_ASSERT_LOCKED in the vlan_ioctl path. ok visa@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_aggr.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/net/if_aggr.c b/sys/net/if_aggr.c
index 10cc3c66b8d..d607d5c6ff5 100644
--- a/sys/net/if_aggr.c
+++ b/sys/net/if_aggr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_aggr.c,v 1.28 2020/03/11 07:01:42 dlg Exp $ */
+/* $OpenBSD: if_aggr.c,v 1.29 2020/04/12 06:59:54 dlg Exp $ */
/*
* Copyright (c) 2019 The University of Queensland
@@ -589,8 +589,10 @@ aggr_clone_destroy(struct ifnet *ifp)
if_detach(ifp);
/* last ref, no need to lock. aggr_p_dtor locks anyway */
+ NET_LOCK();
while ((p = TAILQ_FIRST(&sc->sc_ports)) != NULL)
aggr_p_dtor(sc, p, "destroy");
+ NET_UNLOCK();
free(sc, M_DEVBUF, sizeof(*sc));