summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2025-02-05 15:51:13 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-21 14:01:41 +0100
commit77096420be1fb6a0fda2cdb49847dd984eb5ca62 (patch)
treef4c26eb6b64912d3ca9ffd99aa7c443e0c8d8d40 /net
parentf4ba5e65c92b768ba542353fda2ec8c2ff3faaee (diff)
downloadlinux-77096420be1fb6a0fda2cdb49847dd984eb5ca62.tar.gz
linux-77096420be1fb6a0fda2cdb49847dd984eb5ca62.tar.bz2
linux-77096420be1fb6a0fda2cdb49847dd984eb5ca62.zip
ipv4: use RCU protection in rt_is_expired()
[ 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>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/route.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 9709ec3e2dce..e31aa5a74ace 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -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)