mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
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: fa50d974d1 ("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
852805b6cb
commit
23dca5be79
@@ -362,10 +362,15 @@ static inline int inet_iif(const struct sk_buff *skb)
|
|||||||
static inline int ip4_dst_hoplimit(const struct dst_entry *dst)
|
static inline int ip4_dst_hoplimit(const struct dst_entry *dst)
|
||||||
{
|
{
|
||||||
int hoplimit = dst_metric_raw(dst, RTAX_HOPLIMIT);
|
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);
|
hoplimit = READ_ONCE(net->ipv4.sysctl_ip_default_ttl);
|
||||||
|
rcu_read_unlock();
|
||||||
|
}
|
||||||
return hoplimit;
|
return hoplimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user