Skip to content

Commit 4579bc9

Browse files
pvts-matPlaidCat
authored andcommitted
net: add dev_net_rcu() helper
jira VULN-54027 cve-pre CVE-2025-21764 commit-author Eric Dumazet <[email protected]> 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 <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> (cherry picked from commit 482ad2a) Signed-off-by: Marcin Wcisło <[email protected]>
1 parent 03a02a0 commit 4579bc9

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
@@ -2683,6 +2683,12 @@ struct net *dev_net(const struct net_device *dev)
26832683
return read_pnet(&dev->nd_net);
26842684
}
26852685

2686+
static inline
2687+
struct net *dev_net_rcu(const struct net_device *dev)
2688+
{
2689+
return read_pnet_rcu(&dev->nd_net);
2690+
}
2691+
26862692
static inline
26872693
void dev_net_set(struct net_device *dev, struct net *net)
26882694
{

include/net/net_namespace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static inline struct net *read_pnet(const possible_net_t *pnet)
370370
#endif
371371
}
372372

373-
static inline struct net *read_pnet_rcu(possible_net_t *pnet)
373+
static inline struct net *read_pnet_rcu(const possible_net_t *pnet)
374374
{
375375
#ifdef CONFIG_NET_NS
376376
return rcu_dereference(pnet->net);

0 commit comments

Comments
 (0)