Skip to content

Commit 71b8471

Browse files
edumazetkuba-moo
authored andcommitted
ipv4: use RCU protection in ipv4_default_advmss()
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 <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 071d801 commit 71b8471

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

net/ipv4/route.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,10 +1307,15 @@ static void set_class_tag(struct rtable *rt, u32 tag)
13071307

13081308
static unsigned int ipv4_default_advmss(const struct dst_entry *dst)
13091309
{
1310-
struct net *net = dev_net(dst->dev);
13111310
unsigned int header_size = sizeof(struct tcphdr) + sizeof(struct iphdr);
1312-
unsigned int advmss = max_t(unsigned int, ipv4_mtu(dst) - header_size,
1313-
net->ipv4.ip_rt_min_advmss);
1311+
unsigned int advmss;
1312+
struct net *net;
1313+
1314+
rcu_read_lock();
1315+
net = dev_net_rcu(dst->dev);
1316+
advmss = max_t(unsigned int, ipv4_mtu(dst) - header_size,
1317+
net->ipv4.ip_rt_min_advmss);
1318+
rcu_read_unlock();
13141319

13151320
return min(advmss, IPV4_MAX_PMTU - header_size);
13161321
}

0 commit comments

Comments
 (0)