]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: ethtool: optionally skip rtnl_lock on IOCTL path
authorJakub Kicinski <kuba@kernel.org>
Fri, 5 Jun 2026 00:29:11 +0000 (17:29 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 9 Jun 2026 17:13:06 +0000 (10:13 -0700)
commitf994752b11273ded7ec6b49ae5c1d319eef21743
tree87bfb04531842a49728fc85d9d945ee4466e959d
parentf58a40d07be39823abf2fa1f73b6a839580404f0
net: ethtool: optionally skip rtnl_lock on IOCTL path

Convert the IOCTL path similarly to how we converted Netlink.
The device lookup gets a little hairy. We could take rtnl_lock
unconditionally and drop it before calling the driver (this would
avoid the reference + liveness check). But I think being able
to make progress even if rtnl is dead-locked is quite useful.

First extra concern is handling features. List all the cmds which
modify features and always take rtnl_lock. We could fold this list
into ethtool_ioctl_needs_rtnl() but seems cleaner to keep
ethtool_ioctl_needs_rtnl() driver-related. If a driver changed
features and we were not holding rtnl_lock - warn about it.
It can only happen on buggy ops locked drivers (buggy because
they should have set appropriate "I need rtnl for op X" bit).

Second wrinkle is the PHY ID hack which drops the locks while
sleeping. Convert its static "busy" variable which used to
be protected by rtnl_lock to a field in struct ethtool_netdev_state.
This feature is about identifying an adapter or a port within
a system, so being able to blink multiple LEDs at the same
time is likely not very useful in practice. But it's the simplest
fix, we can add a mutex if someone thinks a system should only
be ID'ing one port at a time.

Reviewed-by: Eric Dumazet <edumazet@google.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20260605002912.3456868-12-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/ethtool.h
net/ethtool/ioctl.c