🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14399

[PATCH net] net: hsr: clean up synced addresses and allmulti in hsr_del_port()

#14399
From: Wenbo Sun
Date: Wed, 11 Nov 2026 06:01
54 lines
10995 bytes
hsr_set_rx_mode() syncs unicast and multicast addresses to slave A and
slave B devices via dev_uc_sync_multiple() and dev_mc_sync_multiple(),
and hsr_change_rx_flags() propagates IFF_ALLMULTI via
dev_set_allmulti().

However, when an HSR device is deleted via hsr_dellink(),
hsr_del_ports() removes all ports from hsr->ports before
unregister_netdevice_queue() invokes hsr_dev_close(). Similarly, when a
slave device is unregistered while the HSR master is UP,
hsr_netdev_notify() calls hsr_del_port() directly. Because
hsr_del_port() does not unsync unicast/multicast addresses or restore
the allmulti count, the slave devices permanently retain synced hardware
addresses and a leaked allmulti reference count after port deletion.

Fix this by calling dev_uc_unsync() and dev_mc_unsync(), and
decrementing allmulti via dev_set_allmulti(port->dev, -1) if
IFF_ALLMULTI is set on the master device, when detaching slave A or
slave B in hsr_del_port().

This issue was identified with the assistance of an LLM-based code
review tool, confirmed by reproducing the leaked allmulti reference
count and synced multicast address in a User-Mode Linux (UML)
environment, and verified in UML that both states are properly cleaned
up upon HSR port deletion.

Fixes: 36b20fcdd966 ("net: hsr: Add support for MC filtering at the slave device")
Signed-off-by: Wenbo Sun <sunwenbo@cmss.chinamobile.com>
---
 net/hsr/hsr_slave.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/hsr/hsr_slave.c b/net/hsr/hsr_slave.c
index a546f70f9cc8..bab0c27dd06a 100644
--- a/net/hsr/hsr_slave.c
+++ b/net/hsr/hsr_slave.c
@@ -245,8 +245,14 @@ void hsr_del_port(struct hsr_port *port)
 		netdev_rx_handler_unregister(port->dev);
 		if (!port->hsr->fwd_offloaded || port->type == HSR_PT_INTERLINK)
 			dev_set_promiscuity(port->dev, -1);
-		if (port->type == HSR_PT_SLAVE_A || port->type == HSR_PT_SLAVE_B)
+		if (port->type == HSR_PT_SLAVE_A ||
+		    port->type == HSR_PT_SLAVE_B) {
 			vlan_vids_del_by_dev(port->dev, master->dev);
+			dev_uc_unsync(port->dev, master->dev);
+			dev_mc_unsync(port->dev, master->dev);
+			if (master->dev->flags & IFF_ALLMULTI)
+				dev_set_allmulti(port->dev, -1);
+		}
 		netdev_upper_dev_unlink(port->dev, master->dev);
 		if (hsr->prot_version == PRP_V1 &&
 		    port->type == HSR_PT_SLAVE_B) {
-- 
2.33.0
Technical Details
Message-ID: <20261111060143.183670-1-sunwenbo@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360875-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360875-linux-kernel-netdev=dewy.ru
From: sunwenbo@cmss.chinamobile.com (Wenbo Sun)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] net: hsr: clean up synced addresses and allmulti in hsr_del_port()
Date: Wed, 11 Nov 2026 14:01:43 +0800
Organization: Usenet Network
Message-ID: <20261111060143.183670-1-sunwenbo@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="787030"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:9OVF2ndEvjGfZ3Uwk2TWZZpLuxY= sha256:b1hIj3zZLVlvXrxLp7N9CUueydh37Qy8MRN3reqfoP0=
	sha1:igCCbSOAk7nhkZOt6AMdvVYm5PQ= sha256:uJTdBziIcyPimNJcM0CIBN/AMoHEvoxAuVnSj1Hwmj0=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 176D1113E20; Wed, 11 Nov 2026 09:04:06 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.75
X-Spam-Status: No, score=-2.75 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key)
	reason="fail (body has been altered)" header.d=cmss.chinamobile.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id IDj-OxpACAcP;
	Wed, 11 Nov 2026 09:03:58 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-360875-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 0E8BB113E18; Wed, 11 Nov 2026 09:03:48 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 7DAB884E57; Wed, 11 Nov 2026 06:02:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794376932;
	b=QYC5/NTCf0FQnhC9eE89A0UuU5jyqGAxtELmM3VylwSt4z2QmLkGss/UEh95hWV2Ab1L
	 1OUl71kE6UbLGoxMepinj2QGnoWicM4RtIDbJmcKg14LuzvNx0h57VgUnih6cx8d2qVoZ
	 WVRoheHrWhbmDm88cQ6gHdjhSxEfKKRB6L55BUaNcC4eMzWL3qGiEfYiX4EyWUrnh7RcB
	 1n2++LoyCEYQFqZ7/2T8wGv0ahQTcxgpfpXBLe8VGOiSUBgS+be20e9Krts/wu5A3EXqm
	 4ZqRwPM6PVrVwPXiH1g3s5UkQNf6WmnCl5NQ1UXeNwE2Ip8OF/ggcsZ09Q1tFcnGi+A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794376932;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo:
	 X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:
	 Received:X-RM-TRANSID:From:To:Cc:Subject:Date:Message-Id:X-Mailer:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=clJ16mqtaU4VebO6eCORWaZIIouvMDiu9cYs0vhp9oQ=;
	b=Tus6GfWLD1ntwUvngrpbrRdQr4DZ/JA24Gtr5KwCRVqsmcX4FWsXVaPZWXALpQbXUd+q
	 4gWyQlq3nHZr787G5kp95v3iX8eFWFad06zqX07yGdkuL1V6s0f86y5nJxVLC5blRyvbe
	 ozwLs1XU4NjE5peAA1/bjMpti/t5v7dVo8girAEj1u270BAzRLmd7cnF7H5+z/4jhQdXK
	 SsKdpIBlkOenQtfyIctFKxJSvmkezZfXkcxT0rigzRJwYnMdL0YfR/VpWTnHib+ONxhGH
	 8IoCey1GN1V7cLfkSqVGZMBTBUZGuGBsxnGBR0unAmYUYLs55rErTzHpe8doTwzdqLA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=B82NAHBp;
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 519A4606AC46;
	Wed, 11 Nov 2026 06:02:12 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=B82NAHBp
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.137
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794376931;
	b=42Sh1bT0WAv1UCVIGEpiaJwBmxfX5Eerr+DWHsw/6RCsoQeZ7kEKb5Fx76/0f6nvv7at
	 RAhrH7UvIK1FeLuyuiDag3dMmFrhtiPyjkWxUM8WN4koQ6CbL45fZsNeVWY1uLGMmj1S+
	 XouCNzp2ANomt0LNyU6zGRKNZF0qppHGq3AHG73WBY/QBSD1p6/2oqtNiyVRKRChe4NMm
	 26eEj4tcH/ODYoqPOUi24jbh6j5RN2s+lphgGJ4EEWPMt3z4q1mvrwXcmZAtzz2FVXrJd
	 WS+/ElUAPJYFjgHwBpyQM2uyX94hGjm76yWAu0CdErN47oMLJgYJ2clNRlkTE4pB4gQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794376931;
	h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:
	 X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From:
	 To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=clJ16mqtaU4VebO6eCORWaZIIouvMDiu9cYs0vhp9oQ=;
	b=cFs5lV92PZcv9/iFripYKFCRgMGyFtQk+AJM7bFr1SDbIMXeyTbrmvqlLtTsJTdpLnPu
	 NUsPAx0AnWzMoqign7j20WCVANDcNJvm6npmo0NYAjnhs/5T0NP6k92UcZPnxeRndRaJp
	 ydXCLvq77ii249pQUMISy02PK132hPBPM+4WStEaWcuhq4xo/bXaP5YTTq3jatA7kzZLp
	 VOP8avz8ki7K9zj/kgyZIlovh+xa0bxiT36NrfqsGDlcgrR/EEMSl6effYd+hEU9zwSLf
	 JdboBb1hJQ24WkFJ6iGR111ZqjDEQzjK+CLjNwme2ID1BmgOPcrcLr3V3VdtD3isfdw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=B82NAHBp;
	arc=none smtp.remote-ip=111.22.67.137
X-Received: from cmccmta4.chinamobile.com (cmccmta4.chinamobile.com [111.22.67.137])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id CD52E606A31C;
	Wed, 11 Nov 2026 06:02:07 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CD52E606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=cmss.chinamobile.com; s=default; l=0;
	h=from:subject:message-id:to:cc:mime-version;
	bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
	b=B82NAHBpjl5lwEA6S+7NHHaJ3+WCHX1PyueGyZBoHRhwg7f03Ul61dwCezWxA2wJZliN5P2Sc26DL
	 rhRWs14sNiO460es2ftG/VzduG7v8ZEr1PRnxi3u6zCV29VwHT8nJsuhifCRTapY4vfCLY0sZSwDFV
	 EWplzW/7ChQ6KCPY=
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87])
	by rmmx-syy-dmz-app04-12004 (RichMail) with SMTP id 2ee46af404da9d7-74870;
	Wed, 11 Nov 2026 14:02:05 +0800 (CST)
X-RM-TRANSID: 2ee46af404da9d7-74870
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from localhost.net (unknown[223.64.115.200])
	by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee86af404dc3a6-d03ed;
	Wed, 11 Nov 2026 14:02:05 +0800 (CST)
X-RM-TRANSID: 2ee86af404dc3a6-d03ed
X-Cc: Simon Horman <horms@kernel.org>,
	Fernando Fernandez Mancera <fmancera@suse.de>,
	MD Danish Anwar <danishanwar@ti.com>,
	Murali Karicheri <m-karicheri2@ti.com>,
	Wojciech Drewek <wojciech.drewek@intel.com>,
	Ravi Gunasekaran <r-gunasekaran@ti.com>,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	sunwenbo@cmss.chinamobile.com,
	1342116488@qq.com
X-Mailer: git-send-email 2.33.0
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list