summaryrefslogtreecommitdiff
path: root/net/ipv4
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2025-02-05 15:51:14 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-21 14:11:15 +0100
commit664830df7cddb52dfc1cec2f3a2870944e842c12 (patch)
tree3212c4d8615f8ef63dc200841a593eda6db68bbf /net/ipv4
parentc11e8f924fc4a0f7e6782c7b47b72aad3ff702aa (diff)
downloadlinux-664830df7cddb52dfc1cec2f3a2870944e842c12.tar.gz
linux-664830df7cddb52dfc1cec2f3a2870944e842c12.tar.bz2
linux-664830df7cddb52dfc1cec2f3a2870944e842c12.zip
ipv4: use RCU protection in inet_select_addr()
[ Upstream commit 719817cd293e4fa389e1f69c396f3f816ed5aa41 ] inet_select_addr() must use RCU protection to make sure the net structure it reads does not disappear. Fixes: c4544c724322 ("[NETNS]: Process inet_select_addr inside a namespace.") Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20250205155120.1676781-7-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/devinet.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index c8b3cf5fba4c..55b8151759bc 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1371,10 +1371,11 @@ __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope)
__be32 addr = 0;
unsigned char localnet_scope = RT_SCOPE_HOST;
struct in_device *in_dev;
- struct net *net = dev_net(dev);
+ struct net *net;
int master_idx;
rcu_read_lock();
+ net = dev_net_rcu(dev);
in_dev = __in_dev_get_rcu(dev);
if (!in_dev)
goto no_in_dev;