Skip to content

Commit

Permalink
ipv4: use RCU protection in ipv4_default_advmss()
Browse files Browse the repository at this point in the history
ipv4_default_advmss() must use RCU protection to make
sure the net structure it reads does not disappear.

Fixes: 2e9589f ("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>
  • Loading branch information
Eric Dumazet authored and Jakub Kicinski committed Feb 7, 2025
1 parent 071d801 commit 71b8471
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1307,10 +1307,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);
}
Expand Down

0 comments on commit 71b8471

Please sign in to comment.