Skip to content

Commit c92854d

Browse files
committed
net: add dev_net_rcu() helper
jira LE-3467 cve CVE-2025-21765 Rebuild_History Non-Buildable kernel-4.18.0-553.58.1.el8_10 commit-author Eric Dumazet <edumazet@google.com> commit 482ad2a dev->nd_net can change, readers should either use rcu_read_lock() or RTNL. We currently use a generic helper, dev_net() with no debugging support. We probably have many hidden bugs. Add dev_net_rcu() helper for callers using rcu_read_lock() protection. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/20250205155120.1676781-2-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit 482ad2a) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 6510a3d commit c92854d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

include/linux/netdevice.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,6 +2468,12 @@ struct net *dev_net(const struct net_device *dev)
24682468
return read_pnet(&dev->nd_net);
24692469
}
24702470

2471+
static inline
2472+
struct net *dev_net_rcu(const struct net_device *dev)
2473+
{
2474+
return read_pnet_rcu(&dev->nd_net);
2475+
}
2476+
24712477
static inline
24722478
void dev_net_set(struct net_device *dev, struct net *net)
24732479
{

include/net/net_namespace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ static inline struct net *read_pnet(const possible_net_t *pnet)
362362
#endif
363363
}
364364

365-
static inline struct net *read_pnet_rcu(possible_net_t *pnet)
365+
static inline struct net *read_pnet_rcu(const possible_net_t *pnet)
366366
{
367367
#ifdef CONFIG_NET_NS
368368
return rcu_dereference(pnet->net);

0 commit comments

Comments
 (0)