Skip to content

Commit 3c8ffcd

Browse files
edumazetkuba-moo
authored andcommitted
ipv6: use RCU protection in ip6_default_advmss()
ip6_default_advmss() needs rcu protection to make sure the net structure it reads does not disappear. Fixes: 5578689 ("[NETNS][IPV6] route6 - make route6 per namespace") 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 afec62c commit 3c8ffcd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

net/ipv6/route.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3196,13 +3196,18 @@ static unsigned int ip6_default_advmss(const struct dst_entry *dst)
31963196
{
31973197
struct net_device *dev = dst->dev;
31983198
unsigned int mtu = dst_mtu(dst);
3199-
struct net *net = dev_net(dev);
3199+
struct net *net;
32003200

32013201
mtu -= sizeof(struct ipv6hdr) + sizeof(struct tcphdr);
32023202

3203+
rcu_read_lock();
3204+
3205+
net = dev_net_rcu(dev);
32033206
if (mtu < net->ipv6.sysctl.ip6_rt_min_advmss)
32043207
mtu = net->ipv6.sysctl.ip6_rt_min_advmss;
32053208

3209+
rcu_read_unlock();
3210+
32063211
/*
32073212
* Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and
32083213
* corresponding MSS is IPV6_MAXPLEN - tcp_header_size.

0 commit comments

Comments
 (0)