summaryrefslogtreecommitdiffstats
path: root/sys/net/if_tpmr.c
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2020-04-12 06:56:37 +0000
committerdlg <dlg@openbsd.org>2020-04-12 06:56:37 +0000
commited1cf1893cb2dbb9c6c2a65b69a8b67920fcc2b9 (patch)
tree3a47986114882cab9bc814e1edc52eae20002cbe /sys/net/if_tpmr.c
parentifpromisc() requires NET_LOCK(), so acquire the lock when changing (diff)
downloadwireguard-openbsd-ed1cf1893cb2dbb9c6c2a65b69a8b67920fcc2b9.tar.xz
wireguard-openbsd-ed1cf1893cb2dbb9c6c2a65b69a8b67920fcc2b9.zip
take NET_LOCK in tpmr_clone_destroy() before calling tpmr_p_dtor()
tpmr_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. found by hrvoje popovski who was testing tpmr with vlan interfaces. vlan(4) asserts that the net lock is held in it's ioctl path, which started this whole bug hunt. ok visa@ (who came up with a similar diff, which hrvoje tested)
Diffstat (limited to 'sys/net/if_tpmr.c')
-rw-r--r--sys/net/if_tpmr.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/net/if_tpmr.c b/sys/net/if_tpmr.c
index d81183fe54e..6a1c7dfc72d 100644
--- a/sys/net/if_tpmr.c
+++ b/sys/net/if_tpmr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tpmr.c,v 1.9 2020/04/11 11:01:03 dlg Exp $ */
+/* $OpenBSD: if_tpmr.c,v 1.10 2020/04/12 06:56:37 dlg Exp $ */
/*
* Copyright (c) 2019 The University of Queensland
@@ -201,12 +201,14 @@ tpmr_clone_destroy(struct ifnet *ifp)
if_detach(ifp);
+ NET_LOCK();
for (i = 0; i < nitems(sc->sc_ports); i++) {
struct tpmr_port *p = SMR_PTR_GET_LOCKED(&sc->sc_ports[i]);
if (p == NULL)
continue;
tpmr_p_dtor(sc, p, "destroy");
}
+ NET_UNLOCK();
free(sc, M_DEVBUF, sizeof(*sc));