🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14377

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

#14377
From: Wenbo Sun
Date: Wed, 11 Nov 2026 03:31
47 lines
9931 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")
Signed-off-by: Wenbo Sun <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: <20261111033114.133296-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-360839-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-360839-linux-kernel-netdev=dewy.ru
From: sunwenbo@cmss.chinamobile.com (Wenbo Sun)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] net: dcb: flush rewrite table on device unregister
Date: Wed, 11 Nov 2026 11:31:14 +0800
Organization: Usenet Network
Message-ID: <20261111033114.133296-1-sunwenbo@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="766719"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:fnRVJht3b5lkoUFHdt6xyxhgP1Q= sha256:7z+OTZBw8pOvV2sSaXAR04OaS1YEYCXIrYHiS7M58hI=
	sha1:6FOBuduq3BTYMRJ2SQDBNCeZO8A= sha256:sjPjeTCb9XyDo/AxFXoSCCJ2qu6l2+uqhWy7feD7EQQ=
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 DC7D6113E10; Wed, 11 Nov 2026 06:33:39 +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 KnlXHZkjVu9v;
	Wed, 11 Nov 2026 06:33:31 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-360839-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 4B3D1113E0A; Wed, 11 Nov 2026 06:33:21 +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 6B56A38C6D; Wed, 11 Nov 2026 03:31:39 +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=1794367898;
	b=GZ00EbBSz2m7/shwAiPEdnr9ZS+cHT9b3QMq1dEDyo+AzOV6IEDPVDrxHl35ckizVjc3
	 uPRMCkBmxJXMWwWOBrcEL4jte9AxvnghRK57tHPrRH4VYsbj8HvXm1h0rMIobXRHoowXj
	 ZOaOkubVb+uYYObuejHu9ruLWsyODBvciYmyZjQRHv/1DBWyhw2cZYIvbGskqtBdh1bXu
	 UrtV5h2MzzAIQtdOx6U3aYj7X+uheAGyeDRJoGf+h15fSU1IiOwnILBi6tBVi9Xdnlppv
	 2+PvLsSzM1fn67Y0tiF9R64jbXi6D8ZSURotLPZOR/9XT7qT6bK66thTqTnbAHM91ug==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794367898;
	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=VXGeJs/cCQO0aCYsOzSzvYGgs1xDorb4m6bYnjZh0dw=;
	b=1DwSSqUKkibLs/ZAJCaMeBXIvv3LD3TZ9+l810k0a3l0i9H2NOd7XFDFfSwv1eASSO1a
	 87+bABAsafyxwpBcrBjTf66rPAaAPQNOSW0xeUab418hBrzDuCElOvw0NIj6iW7XgBhTv
	 sLa+k7KpJO6ijCeqNATkM0MIk+Ca34R6mFqUmHRu798cVs5ebDcrG8/q/URVXCRfiGWdC
	 L8AevNlU6IFwJaXHMi1lzTr73EqoGb+yUF040X3TbyKs4zhD4UtCqpf1nh1RydzCwrB0R
	 uosjpri6WwY9KbNU07v2T/znB7Lnx04I1ywXWhG6Y4+PvgmOb8SOB/CF/XGXuuXO0tQ==
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=xDfexIY+;
	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 9B651606A320;
	Wed, 11 Nov 2026 03:31:38 +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=xDfexIY+
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.135
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794367897;
	b=gEM5+Rb3RzOAKZ8f+WPRjky7w613xN2ggBBtazNdbi5di49NKHPcsfdiYtQnUzSpcuHs
	 cg4i5owZoyV+BcKSNgBHNQlqVzX5HoMmC1us9GLkivGeXiOnapOAjvF91UomRl0AP2GU3
	 zrX990j3u2bHR2PrOJhWtR715xPhXR3IdNOZE/Ssks/YagrlSAalq/rYsQCGUt6B1qKD/
	 PUUSaqFvNN65D6lfL9U2IOpHRDmk0N36EOAROuYECR7Oy7jNIvLwcWy9W0gxuumRfjOmW
	 TqM/bMNKxonnbDDwauVNDSbHJN3r3b2EOuLdrcbqhVpIHPNQSSkIDz84GR6Wn98q9ng==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794367897;
	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=VXGeJs/cCQO0aCYsOzSzvYGgs1xDorb4m6bYnjZh0dw=;
	b=x5CmjGPhykRxPtgvRn30zsbDHMZVTKndW9CUCCSAG4r2fbBywAf2JLe9JytYInjezL67
	 ssqGMRZqGSqoKkG11dlriabhI9UAdRr/XGuwEKIoEjKSnHACyuRsRTyIJ9cSml0xPcnNm
	 0EBMrkqifjq7yZYjaoUBsZ5CaeBcgEVEX6bfKlHkP08CF70195xl6B7fha6Xu1cdMPod8
	 iGLOpZn918KAJCqNPnCBc/J8b0QuICXuS22MsVMSM+Gug/CJUOiS3s5VvVI7ehYyyfSBq
	 6qb0H0+6N78kk8An11AJUsHq39B3i5jZkXlioonTmgrCIqUhEO5w2UgZB9bxngmh1Hg==
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=xDfexIY+;
	arc=none smtp.remote-ip=111.22.67.135
X-Received: from cmccmta2.chinamobile.com (cmccmta2.chinamobile.com [111.22.67.135])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D5C0606A324;
	Wed, 11 Nov 2026 03:31:34 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4D5C0606A324
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=xDfexIY+AegydL0styz938D2k0WKy6PzbqScekAkINIgJcX1J1o6ot9wb28z/Fh2A/XSA6RLz3nPP
	 VFZTXqEh0+s0JmkqKRDnXqoiJSUUPAtbZBuUV1ZSKm0K7qrm9Kmn2quAIS/qCmqZOPLQGfsC+sx8CX
	 IYUyJJ7PCCzHAEzk=
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-app07-12007 (RichMail) with SMTP id 2ee76af3e192ff8-d48e9;
	Wed, 11 Nov 2026 11:31:33 +0800 (CST)
X-RM-TRANSID: 2ee76af3e192ff8-d48e9
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from localhost.net (unknown[223.64.115.200])
	by rmsmtp-syy-appsvr02-12002 (RichMail) with SMTP id 2ee26af3e193df5-cceb3;
	Wed, 11 Nov 2026 11:31:33 +0800 (CST)
X-RM-TRANSID: 2ee26af3e193df5-cceb3
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