🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14868

[PATCH net-next v2] net: dcb: flush rewrite table on device unregister

#14868
From: Wenbo Sun
Date: Thu, 12 Nov 2026 03:36
57 lines
10373 bytes
In dcbnl_flush_dev(), which is called upon NETDEV_UNREGISTER for net
devices with dcbnl_ops, only entries in dcb_app_list matching
dev->ifindex are freed. The entries in dcb_rewr_list added via
dcb_setrewr() are not flushed.

This causes a memory leak of struct dcb_app_type nodes in dcb_rewr_list
when a DCB-capable net device is unregistered, and leaves stale entries
in the global rewrite table that could inappropriately match if another
net device later reuses the same ifindex.

Iterate over dcb_rewr_list in dcbnl_flush_dev() and remove and free all
entries matching dev->ifindex, mirroring the cleanup performed for
dcb_app_list.

This issue was found via LLM-assisted code review, confirmed by
reproducing the leaked rewrite table entry upon netdevice unregistration
in a User-Mode Linux (ARCH=um) environment, and verified in UML by
confirming that all rewrite table entries for the unregistered netdevice
are flushed.

Fixes: 622f1b2fae2e ("net: dcb: add new rewrite table")
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
Tested-by: Daniel Machon <daniel.machon@microchip.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Wenbo Sun <sunwenbo@cmss.chinamobile.com>
---
v2:
  - Target net-next instead of net, as this has never worked and is not
    a regression (Petr Machata).
  - Add Reviewed-by and Tested-by tags from Daniel Machon (verified on
    lan969x) and Reviewed-by tag from Petr Machata.
v1: https://lore.kernel.org/netdev/20261111033114.133296-1-sunwenbo@cmss.chinamobile.com/

 net/dcb/dcbnl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index ad0aebe0ad3d..95250658ecc1 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -2393,6 +2393,13 @@ static void dcbnl_flush_dev(struct net_device *dev)
 		}
 	}
 
+	list_for_each_entry_safe(itr, tmp, &dcb_rewr_list, list) {
+		if (itr->ifindex == dev->ifindex) {
+			list_del(&itr->list);
+			kfree(itr);
+		}
+	}
+
 	spin_unlock_bh(&dcb_lock);
 }
 
-- 
2.33.0
Technical Details
Message-ID: <20261112033622.40333-1-sunwenbo@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361482-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361482-linux-kernel-netdev=dewy.ru
From: sunwenbo@cmss.chinamobile.com (Wenbo Sun)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2] net: dcb: flush rewrite table on device unregister
Date: Thu, 12 Nov 2026 11:36:22 +0800
Organization: Usenet Network
Message-ID: <20261112033622.40333-1-sunwenbo@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1001569"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Y20beHvQUh5hzVoo8bKR1e8gsnk= sha256:FvNLEsAXHYXNXR8fmVNLpx/xfZ+1EUDbmPBf9i1njaQ=
	sha1:UAsVidYvEKxYZtDYbZN2jWTzGik= sha256:JTmfvDt+arMP/7oWtd1Dc3xWDpQ2eiCo49oUSMwqEMg=
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 12A2A1140E8; Thu, 12 Nov 2026 06:41:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.751
X-Spam-Status: No, score=-2.751 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]
	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 APkA8i_4RV4y;
	Thu, 12 Nov 2026 06:41:14 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-361482-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 7935E1140B3; Thu, 12 Nov 2026 06:41:02 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id F31B638F0F; Thu, 12 Nov 2026 03:36:46 +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=1794454606;
	b=gqtnQRNIRSDqj3/3+uCbjsrGg6fY+21jjVTbF+xpFpmviZc8+zJ4MuxP8xfpKp3Ht1qx
	 aKloWWuNzNP2pPlye7XmAmBEGbcWgJAHYBE6NpgVOHozjzoug1r955BoRyex7njZ4Upfv
	 ttd3FyCVHlhDYaaZHDND7555JNCVJCHyYjcF3S14p+1Q1/HG/3eXXBybo0EER87xg7J4y
	 TBryupMKT1EvqJ/dYFf6iYRsMz7D2iqmmZFBiY4Bd9j8lg1qAfyiLpRdMZr5dVIU8ovSn
	 PndQCBBOWoaUXEvHL3J3xbvr00CjcmxQTqPdWgM+Pg9jxBPs6kAHgB9dvHXFc7spIdg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794454606;
	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=gN9Tyx2FqNCHFZUeFzXAvqkF5h5jT66EcfPlDZkPMDo=;
	b=MttN0T25cd60z2JcD6vSdtDqTyTbaTWFS6bLHAdKT4lQyeSsw3vhRtFC2I7vlr08AyGD
	 UpBCaPypaYZfm7P590QEty88+grD7jyvKl4z7ifVEmlIZfEZKWgMWbs1owuMUIlomvi0W
	 B7MN4h+H+ca04noqK0Jmiqk2KlOYaR8AI/xVNipZNAY0Nn8qCSove12sZQAbm89+uuGAF
	 fRjUuRw4XeDnVpl45n0UBFniI5sbl8yuI8TC5Q1dnG8NyfPT3nuBh/YC/44Mbgxuhga8H
	 zy5R2sDyjMpj6aA1tVZAkpLGYi3SKDcfKSFSVoElaTssyAmL+mfOi+BPIA/0iruGg8A==
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=RiVU9U+I;
	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 EBF24606A32E;
	Thu, 12 Nov 2026 03:36:45 +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=RiVU9U+I
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.151
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794454605;
	b=gILEAss6GTjZuZCqgJmhdRMcO3YFcHY1KLY69IcdaFLVcX4NDd8xWw81P88om19u+oxe
	 unV5J3vOLKtEfRuyNVAjlUhpHP02kEI2jjA5ToKNm0rSguyK2oYl5zXfmtwGnjqyBBVXK
	 WGPKhIaixXSFEvw6NyfRD+14bS3fmWtZarN3RvfmsjbtsWAMfLRh30yIdbpsSust0VFwT
	 CbERq2nr628M8u4GtAkXkYE5urW8f0DBEqpJtp0AmZF2VsKmtsXFTfqqEGg5Vb1QdyIvy
	 7lUiTafZ6Y5A5QlSoUuxAdzChZV2UiWEFsXL1HTq7u8K1da/jNGm1tPL2etLwy+qgSg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794454605;
	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=gN9Tyx2FqNCHFZUeFzXAvqkF5h5jT66EcfPlDZkPMDo=;
	b=4u1OUGZu4b0N8v3+qzJqk5n0MVtsosQU8tKhJhwnn+2sPee4he12RveD275HXbrmkepR
	 yjHAdax6vMbND68Mz5GsTy1nuwh//9WGF64e6318Ayr1kpcBGLzS1dSWAfIB+S0Qxmt9O
	 xQE0M41STlMaQMcxEk2Iaay1r9q2Reg1YbO8K+Oq1lWtMqQRb/h7D7QdH4i882REaKjNl
	 hDrG5YH5pcbvsF+kaa2Yed7uHUKqm70vUUPGmsN12Fg2K5ZoDlakPZR33JT/01GsruzL+
	 4P1JaIur61eCzYiRrYN+5OWfCCRSz4L/yWrn7DSkarf+W1CJyy6auC8Br06ywMZftYg==
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=RiVU9U+I;
	arc=none smtp.remote-ip=111.22.67.151
X-Received: from cmccmta8.chinamobile.com (cmccmta8.chinamobile.com [111.22.67.151])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 7CE44606A31C;
	Thu, 12 Nov 2026 03:36:43 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7CE44606A31C
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=RiVU9U+I/YcePVre89W+4mKr2PW4M+vRlCft7YfevsOEeNbZRccAJ0iIILRgDkoWU9Ed6qVvXzgb1
	 uiwzLB1pJAoLtPMDf/TuKI5iRkH3TaCuCC5NwGpohUZeLe09NAgIFr0FewhwgkmzaekQEnixwmipTg
	 P3uMtrHsMWUnyiaU=
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-app06-12006 (RichMail) with SMTP id 2ee66af53445443-aa185;
	Thu, 12 Nov 2026 11:36:41 +0800 (CST)
X-RM-TRANSID: 2ee66af53445443-aa185
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from localhost.net (unknown[112.23.105.204])
	by rmsmtp-syy-appsvr02-12002 (RichMail) with SMTP id 2ee26af53448136-f157a;
	Thu, 12 Nov 2026 11:36:41 +0800 (CST)
X-RM-TRANSID: 2ee26af53448136-f157a
X-Cc: Alexei Lazar <alazar@nvidia.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