Skip to content

Commit

Permalink
ipv4: use RCU protection in rt_is_expired()
Browse files Browse the repository at this point in the history
rt_is_expired() must use RCU protection to make
sure the net structure it reads does not disappear.

Fixes: e84f84f ("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>
  • Loading branch information
Eric Dumazet authored and Jakub Kicinski committed Feb 7, 2025
1 parent 71b8471 commit dd205fc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion net/ipv4/route.c
Original file line number Diff line number Diff line change
@@ -390,7 +390,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)

0 comments on commit dd205fc

Please sign in to comment.