Skip to content

Commit dd205fc

Browse files
edumazetkuba-moo
authored andcommitted
ipv4: use RCU protection in rt_is_expired()
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 <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 71b8471 commit dd205fc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

net/ipv4/route.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,13 @@ static inline int ip_rt_proc_init(void)
390390

391391
static inline bool rt_is_expired(const struct rtable *rth)
392392
{
393-
return rth->rt_genid != rt_genid_ipv4(dev_net(rth->dst.dev));
393+
bool res;
394+
395+
rcu_read_lock();
396+
res = rth->rt_genid != rt_genid_ipv4(dev_net_rcu(rth->dst.dev));
397+
rcu_read_unlock();
398+
399+
return res;
394400
}
395401

396402
void rt_cache_flush(struct net *net)

0 commit comments

Comments
 (0)