Skip to content

Commit 719817c

Browse files
edumazetkuba-moo
authored andcommitted
ipv4: use RCU protection in inet_select_addr()
inet_select_addr() must use RCU protection to make sure the net structure it reads does not disappear. Fixes: c4544c7 ("[NETNS]: Process inet_select_addr inside a namespace.") Signed-off-by: Eric Dumazet <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent dd205fc commit 719817c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/ipv4/devinet.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,10 +1371,11 @@ __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope)
13711371
__be32 addr = 0;
13721372
unsigned char localnet_scope = RT_SCOPE_HOST;
13731373
struct in_device *in_dev;
1374-
struct net *net = dev_net(dev);
1374+
struct net *net;
13751375
int master_idx;
13761376

13771377
rcu_read_lock();
1378+
net = dev_net_rcu(dev);
13781379
in_dev = __in_dev_get_rcu(dev);
13791380
if (!in_dev)
13801381
goto no_in_dev;

0 commit comments

Comments
 (0)