From 76eabb2a66448d2a52eac7e4eea69c8f9d627a79 Mon Sep 17 00:00:00 2001 From: mvs Date: Tue, 23 Feb 2021 15:13:59 +0000 Subject: 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(-) (limited to 'sys') 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); -- cgit v1.2.3