]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rtnetlink: use dev_isalive() in rtnl_getlink()
authorEric Dumazet <edumazet@google.com>
Wed, 3 Jun 2026 18:08:31 +0000 (18:08 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 5 Jun 2026 01:16:14 +0000 (18:16 -0700)
commitf3c496105472f353ff7428569ea4b6a6a61caf8e
tree47606edc07f229040eaf42deb8440e7c99009cfd
parentc1424df7ff82598a6deba11a63c433b645ab19bb
rtnetlink: use dev_isalive() in rtnl_getlink()

rtnl_getlink() uses an RCU lookup to get the netdevice pointer.

When/If rtnl_lock() is used, we should check if the netdevice is not
being dismantled before potentially perform illegal actions.

Move dev_isalive() out of net/core/net-sysfs.c and make it available
in net/core/dev.h.

Return -ENODEV if rtnl_getlink() finds a device which is currently
being dismantled and RTNL is requested.

Fixes: e896e5c0734b ("rtnetlink: do not acquire RTNL in rtnl_getlink() with RTEXT_FILTER_NAME_ONLY")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Link: https://patch.msgid.link/20260603180831.1024716-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/dev.h
net/core/net-sysfs.c
net/core/rtnetlink.c