]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ipv4: use RCU protection in rt_is_expired()
authorEric Dumazet <edumazet@google.com>
Wed, 5 Feb 2025 15:51:13 +0000 (15:51 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 11:47:21 +0000 (12:47 +0100)
[ Upstream commit dd205fcc33d92d54eee4d7f21bb073af9bd5ce2b ]

rt_is_expired() must use RCU protection to make
sure the net structure it reads does not disappear.

Fixes: e84f84f27647 ("netns: place rt_genid into struct net")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250205155120.1676781-6-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/route.c

index c34386a9d99b4a42026e2d114ab3278407b737f4..a2a7f2597e201a6a2125fcc54d1554691fa3c18f 100644 (file)
@@ -423,7 +423,13 @@ static inline int ip_rt_proc_init(void)
 
 static inline bool rt_is_expired(const struct rtable *rth)
 {
-       return rth->rt_genid != rt_genid_ipv4(dev_net(rth->dst.dev));
+       bool res;
+
+       rcu_read_lock();
+       res = rth->rt_genid != rt_genid_ipv4(dev_net_rcu(rth->dst.dev));
+       rcu_read_unlock();
+
+       return res;
 }
 
 void rt_cache_flush(struct net *net)