From 1d0e1a71fb1b89e2297349602129b314705c00ba Mon Sep 17 00:00:00 2001 From: mvs Date: Tue, 23 Feb 2021 15:13:58 +0000 Subject: [PATCH] Wrap by netlock the whole foreach loop which calls switch_port_detach() in switch_clone_destroy(). This fixes netlock assertion within underlay ifpromisc(). The problem was reported by hrvoje@ [1]. "why not" by deraadt@ 1. https://marc.info/?l=openbsd-bugs&m=161338077403538&w=2 --- sys/net/if_switch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/net/if_switch.c b/sys/net/if_switch.c index 15c6e77065d..447e164e5b0 100644 --- a/sys/net/if_switch.c +++ b/sys/net/if_switch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_switch.c,v 1.40 2021/01/19 19:39:14 mvs Exp $ */ +/* $OpenBSD: if_switch.c,v 1.41 2021/02/23 15:13:58 mvs Exp $ */ /* * Copyright (c) 2016 Kazuya GODA @@ -196,6 +196,7 @@ switch_clone_destroy(struct ifnet *ifp) struct switch_port *swpo, *tp; struct ifnet *ifs; + NET_LOCK(); TAILQ_FOREACH_SAFE(swpo, &sc->sc_swpo_list, swpo_list_next, tp) { if ((ifs = if_get(swpo->swpo_ifindex)) != NULL) { switch_port_detach(ifs); @@ -204,6 +205,7 @@ switch_clone_destroy(struct ifnet *ifp) log(LOG_ERR, "failed to cleanup on ifindex(%d)\n", swpo->swpo_ifindex); } + NET_UNLOCK(); LIST_REMOVE(sc, sc_switch_next); bstp_destroy(sc->sc_stp); swofp_destroy(sc); -- 2.20.1