summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2025-02-05 15:51:18 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-21 14:01:42 +0100
commit713a40c892f40300d63691d9f85b2a23b48fe1e8 (patch)
tree5e4c02bc1aeacc5aa1d6a42820aff77fc9704514 /net
parenta575827791918418a9565734d941624775c3de28 (diff)
downloadlinux-713a40c892f40300d63691d9f85b2a23b48fe1e8.tar.gz
linux-713a40c892f40300d63691d9f85b2a23b48fe1e8.tar.bz2
linux-713a40c892f40300d63691d9f85b2a23b48fe1e8.zip
ipv6: use RCU protection in ip6_default_advmss()
[ Upstream commit 3c8ffcd248da34fc41e52a46e51505900115fc2a ] ip6_default_advmss() needs rcu protection to make sure the net structure it reads does not disappear. Fixes: 5578689a4e3c ("[NETNS][IPV6] route6 - make route6 per namespace") Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/20250205155120.1676781-11-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/ipv6/route.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 8ebfed5d6323..2736dea77575 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3196,13 +3196,18 @@ static unsigned int ip6_default_advmss(const struct dst_entry *dst)
{
struct net_device *dev = dst->dev;
unsigned int mtu = dst_mtu(dst);
- struct net *net = dev_net(dev);
+ struct net *net;
mtu -= sizeof(struct ipv6hdr) + sizeof(struct tcphdr);
+ rcu_read_lock();
+
+ net = dev_net_rcu(dev);
if (mtu < net->ipv6.sysctl.ip6_rt_min_advmss)
mtu = net->ipv6.sysctl.ip6_rt_min_advmss;
+ rcu_read_unlock();
+
/*
* Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and
* corresponding MSS is IPV6_MAXPLEN - tcp_header_size.