🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
2 messages
2 total messages Started by Wenbo Sun Thu, 12 Nov 2026 03:36
[PATCH net-next v2] net: dcb: flush rewrite table on device unregister
#14868
Author: 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
Re: [PATCH net-next v2] net: dcb: flush rewrite table on device unregister
#17519
Author: patchwork-bot+netdevbpf
Date: Tue, 17 Nov 2026 00:00
27 lines
8840 bytes
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 12 Nov 2026 11:36:22 +0800 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: dcb: flush rewrite table on device unregister
    https://git.kernel.org/netdev/net/c/6836fa400109

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads