* [PATCH net-next] net: use dev_net_rcu() in __hw_addr_changed()
@ 2026-11-28 8:36 Yuyang Huang
2026-12-04 5:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Yuyang Huang @ 2026-11-28 8:36 UTC (permalink / raw)
To: Yuyang Huang
Cc: David S. Miller, Aleksandr Loktionov, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Stanislav Fomichev,
netdev
Commit 646cb8868bd2 ("net: add a generation counter for dev->mc
changes") bumps a per netns counter on every dev->mc change, and finds
the netns with dev_net(). Not all callers hold RTNL, so this read can
race with __dev_change_net_namespace() updating dev->nd_net. At worst
the old netns gets the bump, which is harmless, but the read is still
lockless and should be marked as such.
Use dev_net_rcu() under rcu_read_lock() instead. The address list lock
alone does not satisfy the RCU lockdep check.
Found by Sashiko AI review. Theoretical, not seen at runtime.
Link: https://lore.kernel.org/netdev/179185709988.434549.15422498299449004512@kernel.org/
Signed-off-by: Yuyang Huang <yuyanghuang@google.com>
---
net/core/dev_addr_lists.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index b6f25e487984..700d9247ac0c 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -30,7 +30,9 @@ static void __hw_addr_changed(struct netdev_hw_addr_list *list)
if (!list->is_dev_mc)
return;
dev = container_of(list, struct net_device, mc);
- atomic_inc(&dev_net(dev)->dev_mc_genid);
+ rcu_read_lock();
+ atomic_inc(&dev_net_rcu(dev)->dev_mc_genid);
+ rcu_read_unlock();
}
static void __hw_addr_count_add(struct netdev_hw_addr_list *list, int value)
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net: use dev_net_rcu() in __hw_addr_changed()
2026-11-28 8:36 [PATCH net-next] net: use dev_net_rcu() in __hw_addr_changed() Yuyang Huang
@ 2026-12-04 5:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-12-04 5:00 UTC (permalink / raw)
To: Yuyang Huang
Cc: davem, aleksandr.loktionov, edumazet, kuba, pabeni, horms,
sdf.kernel, netdev
Hello:
This patch was applied to netdev/net-next.git (main)
by Willem de Bruijn <willemb@google.com>:
On Sat, 28 Nov 2026 17:36:39 +0900 you wrote:
> Commit 646cb8868bd2 ("net: add a generation counter for dev->mc
> changes") bumps a per netns counter on every dev->mc change, and finds
> the netns with dev_net(). Not all callers hold RTNL, so this read can
> race with __dev_change_net_namespace() updating dev->nd_net. At worst
> the old netns gets the bump, which is harmless, but the read is still
> lockless and should be marked as such.
>
> [...]
Here is the summary with links:
- [net-next] net: use dev_net_rcu() in __hw_addr_changed()
https://git.kernel.org/netdev/net-next/c/04d969487f83
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 5:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 8:36 [PATCH net-next] net: use dev_net_rcu() in __hw_addr_changed() Yuyang Huang
2026-12-04 5:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox