diff options
| author | Eric Dumazet <edumazet@google.com> | 2025-02-05 18:51:10 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-21 15:57:20 +0300 |
| commit | afd983f102f8de01f59ec7ca5a8a49335ffe8c1a (patch) | |
| tree | 8d722bd20e0836135e4a7c8bec2a842b9deb33cf /include | |
| parent | 8783ceeee797d9aa9cfe150690fb9d0bac8cc459 (diff) | |
| download | linux-afd983f102f8de01f59ec7ca5a8a49335ffe8c1a.tar.xz | |
ipv4: add RCU protection to ip4_dst_hoplimit()
[ Upstream commit 469308552ca4560176cfc100e7ca84add1bebd7c ]
ip4_dst_hoplimit() must use RCU protection to make
sure the net structure it reads does not disappear.
Fixes: fa50d974d104 ("ipv4: Namespaceify ip_default_ttl sysctl knob")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250205155120.1676781-3-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/net/route.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/include/net/route.h b/include/net/route.h index 51a45b1887b5..0171e9e1bbea 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -357,10 +357,15 @@ static inline int inet_iif(const struct sk_buff *skb) static inline int ip4_dst_hoplimit(const struct dst_entry *dst) { int hoplimit = dst_metric_raw(dst, RTAX_HOPLIMIT); - struct net *net = dev_net(dst->dev); - if (hoplimit == 0) + if (hoplimit == 0) { + const struct net *net; + + rcu_read_lock(); + net = dev_net_rcu(dst->dev); hoplimit = READ_ONCE(net->ipv4.sysctl_ip_default_ttl); + rcu_read_unlock(); + } return hoplimit; } |
