From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387171; b=4IRNiImwECL/VdAD8aT8U4ldnSiE15KvO7elr05onfI6ShbILwFML+LndLrN+W9KSQHu w/T7nPb4z9LIyE/5shO2NDHTXWPMh2Q4wgMZo1KAz9DZt+tXlkoCjy2aDF0SZPXflF3KO KlgrlANLNKyCI5xDIme+M1X0mjjYCCTnCyPQdORCXeGI+7lCCMuHdbFnjne0BhvVXSRwl MasdwkMKv/tLPuN/XH3NQEl5mrPDJNOCQmY7cYO7Tx6sLrt8V+p5E2Auoi6yEocBi0X0v tCvqbOxy7Cyqt0VLvTjwAAtzn11mz2jQoTXZLFxKdXZPV0Q6TUrfO1TUAD3iWYXBpBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387171; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=a3YWhrqX/VGppUZsnujvL0epTs0Wsyg3og3XubKOU4U=; b=lPVD8AwC/rNFRJBO6DHpUe+T2ctqpA0DRnG+N2ifVF8JAYlDF3GTk7938aZt3TZcWHgf mEN7Rb9wg4sHJSvNEa8Z3fJ34oPWQHpw2BdM83V0k7m32zAF0Mk3dsrmKpCC6rl7UK4Md lugYTmnLr8jhi/I0HTi4t3XaJCjGjSgfONBEJnMfq+WFslqJso3mP0SiJrRRkCLcGNZJG p1TsgL2QdjsOUX/jEpmnon1stXLRlUulrCZNYaB/29zM7Zjib8XIaGiRazf1a8jTfLWHU ppjBb/OKJ9kGpB4kkfyBjp2Fi+dn0C8/EHSVZkeP2sNElNvInxP4+LWfoJbmfMvXevQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Ac2POhsB; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54E22606A322; Fri, 4 Dec 2026 12:26:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Ac2POhsB Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC01A1F000C2; Fri, 4 Dec 2026 12:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387171; bh=a3YWhrqX/VGppUZsnujvL0epTs0Wsyg3og3XubKOU4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ac2POhsB2Kw3wkN7iaX3wo5n2USHz33QuyM8zdff2dVQsRg7QXAS5ep7uuhfFoYmG JyC78oDXtjlNCRQFmcse8iH3QP+9oqS1eU+JbIo8NLY/D2s27Ezc0CmJtdVp671Ukn aN1AOWL5Qr6pKlmeH0wHfI6uo5Vt0cm6Lm0TpJE8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ido Schimmel , Cheng Yongkang , Paolo Abeni , Sasha Levin Subject: [PATCH 6.1 0131/1059] net: bridge: disable MRP ports before the FDB flush in del_nbp() Date: Fri, 4 Dec 2026 18:54:22 +0900 Message-ID: <20261204100647.615577934@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cheng Yongkang [ Upstream commit 37dfd0efbfffc20a57e41c2eb349ac49b1ca1ff8 ] del_nbp() flushes the port's FDB entries before it unregisters the RX handler. For a normal port, br_stp_disable_port() moves the port to BR_STATE_DISABLED before this cleanup. That does not hold for an MRP ring port. br_set_state() ignores state changes while BR_MRP_AWARE_BIT is set, so br_stp_disable_port() leaves the port state alone. br_mrp_port_del() then restores forwarding when the bridge is up before clearing the bit. A frame received between br_fdb_cleanup_by_dst() and netdev_rx_handler_unregister() can therefore create a new FDB entry referencing the dying port. Nothing removes that entry before destroy_nbp_rcu() frees the port, so a later frame to the learned MAC can be forwarded through the freed port. Remove the MRP and CFM instances before disabling the port, so that br_stp_disable_port() actually transitions it to BR_STATE_DISABLED. With CONFIG_BRIDGE_VLAN_FILTERING=y, synchronize_net() in nbp_vlan_group_unpublish() also drains receive paths that could still learn with the old state before the final FDB cleanup. Found through an LLM-assisted source code analysis workflow and reproduced on net with KASAN and CONFIG_BRIDGE_VLAN_FILTERING=y in QEMU. A diagnostic switchdev module accepts MRP objects and delays the NETDEV_CHANGEUPPER callback for 1.5 s, holding del_nbp() after the FDB cleanup and before RX handler removal. The reproducer floods the MRP port with rotating source MACs, waits for the port's RCU callback through the module's rcu_barrier(), then sends frames to those MACs from another port. The unpatched kernel reports: BUG: KASAN: slab-use-after-free in br_forward+0xb1/0x820 Call Trace: br_forward+0xb1/0x820 br_handle_frame_finish+0x148b/0x1e50 br_handle_frame+0x90a/0x15c0 With this patch, three runs of six cycles each reach the delay without a KASAN report. Fixes: 6536993371fa ("bridge: mrp: Integrate MRP into the bridge") Suggested-by: Ido Schimmel Link: https://lore.kernel.org/netdev/20261012123051.GA714215@shredder/ Closes: https://lore.kernel.org/netdev/20261022090431.3641707-1-teel4res@gmail.com/ Signed-off-by: Cheng Yongkang Reviewed-by: Ido Schimmel Link: https://patch.msgid.link/20261101044840.1595584-1-1020691186@qq.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/bridge/br_if.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 169a18f099fd2..1ccd1b8dbf6d0 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -339,13 +339,13 @@ static void del_nbp(struct net_bridge_port *p) nbp_delete_promisc(p); + br_mrp_port_del(br, p); + br_cfm_port_del(br, p); + spin_lock_bh(&br->lock); br_stp_disable_port(p); spin_unlock_bh(&br->lock); - br_mrp_port_del(br, p); - br_cfm_port_del(br, p); - br_ifinfo_notify(RTM_DELLINK, NULL, p); list_del_rcu(&p->list); -- 2.53.0