From d6747eafa9b6520e83a135aebaca97096a5d2b5e Mon Sep 17 00:00:00 2001 From: Kristof Provost Date: Fri, 15 Mar 2019 11:21:20 +0000 Subject: [PATCH] bridge: Fix panic if the STP root is removed If the spanning tree root interface is removed from the bridge we panic on the next 'ifconfig'. While the STP code is notified whenever a bridge member interface is removed from the bridge it does not clear the bs_root_port. This means bs_root_port can still point at an bridge_iflist which has been free()d. The next access to it will panic. Explicitly check if the interface we're removing in bstp_destroy() is the root, and if so re-assign the roles, which clears bs_root_port. Reviewed by: philip MFC after: 2 weeks --- sys/net/bridgestp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c index dbdd1bcf9ce8..366873ec9293 100644 --- a/sys/net/bridgestp.c +++ b/sys/net/bridgestp.c @@ -2274,4 +2274,7 @@ bstp_destroy(struct bstp_port *bp) taskqueue_drain(taskqueue_swi, &bp->bp_statetask); taskqueue_drain(taskqueue_swi, &bp->bp_rtagetask); taskqueue_drain(taskqueue_swi, &bp->bp_mediatask); + + if (bp->bp_bs->bs_root_port == bp) + bstp_assign_roles(bp->bp_bs); }