diff options
| author | Eric Dumazet <edumazet@google.com> | 2025-02-05 15:51:12 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-21 14:01:41 +0100 |
| commit | f4ba5e65c92b768ba542353fda2ec8c2ff3faaee (patch) | |
| tree | ee4ed8a1a82d36904c5d5433a5d32aa2869eadcd | |
| parent | ec9af76451095b82680012bb6d3575e34a6ee205 (diff) | |
| download | linux-f4ba5e65c92b768ba542353fda2ec8c2ff3faaee.tar.gz linux-f4ba5e65c92b768ba542353fda2ec8c2ff3faaee.tar.bz2 linux-f4ba5e65c92b768ba542353fda2ec8c2ff3faaee.zip | |
ipv4: use RCU protection in ipv4_default_advmss()
[ Upstream commit 71b8471c93fa0bcab911fcb65da1eb6c4f5f735f ]
ipv4_default_advmss() must use RCU protection to make
sure the net structure it reads does not disappear.
Fixes: 2e9589ff809e ("ipv4: Namespaceify min_adv_mss sysctl knob")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250205155120.1676781-5-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | net/ipv4/route.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 2a27913588d0..9709ec3e2dce 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1294,10 +1294,15 @@ static void set_class_tag(struct rtable *rt, u32 tag) static unsigned int ipv4_default_advmss(const struct dst_entry *dst) { - struct net *net = dev_net(dst->dev); unsigned int header_size = sizeof(struct tcphdr) + sizeof(struct iphdr); - unsigned int advmss = max_t(unsigned int, ipv4_mtu(dst) - header_size, - net->ipv4.ip_rt_min_advmss); + unsigned int advmss; + struct net *net; + + rcu_read_lock(); + net = dev_net_rcu(dst->dev); + advmss = max_t(unsigned int, ipv4_mtu(dst) - header_size, + net->ipv4.ip_rt_min_advmss); + rcu_read_unlock(); return min(advmss, IPV4_MAX_PMTU - header_size); } |
