linux/net/ethtool
Alexander Duyck 1b82958f3f net: ethtool: keep rtnl_lock for the ioctl self test
An offline self test that brings the interface down and back up with
netif_close() / netif_open() requires rtnl_lock for both. Since the
ethtool IOCTL path became rtnl-optional for ops-locked drivers, the
ETHTOOL_TEST ioctl runs holding only the netdev instance lock, so on an
ops-locked driver the self test now tears the device down without
rtnl_lock.

With lockdep this reproduces deterministically on every offline self
test on such a driver; note the sole lock held is the instance lock, not
rtnl:

  WARNING: suspicious RCU usage
  net/core/netpoll.c:207 suspicious rcu_dereference_protected() usage!
  1 lock held by ethtool/107:
   #0: (&dev->lock){+.+.}, at: dev_ethtool
  Call Trace:
   netpoll_poll_disable
   __dev_close_many
   netif_close_many
   netif_close
   fbnic_self_test
   dev_ethtool_locked
   dev_ethtool
   dev_ioctl
   sock_ioctl
   __x64_sys_ioctl

Without lockdep the same condition trips ASSERT_RTNL() in
__dev_close_many() / __dev_open(); that check only samples the global
rtnl state, so it can be masked by a concurrent rtnl holder, but the
device is still being reconfigured without the lock it requires.

The ethtool self_test is a legacy ioctl-only command, so an ETHTOOL_TEST
case is only needed on the ioctl path. Add an opt-in bit for drivers whose
self test needs rtnl_lock and set it on the ops-locked drivers whose
offline self test tears the interface down and up:

  - fbnic (ops-locked via queue_mgmt_ops): fbnic_self_test() offline path
    uses netif_close() / netif_open().
  - bnxt (ops-locked via queue_mgmt_ops): bnxt_self_test() offline path
    goes through bnxt_close_nic() / bnxt_half_open_nic() /
    bnxt_half_close_nic() / bnxt_open_nic(), which close and reopen the
    device.

Fixes: f994752b11 ("net: ethtool: optionally skip rtnl_lock on IOCTL path")
Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/178942019771.7700.338431553546884773.stgit@ahduyck-xeon-server.home.arpa
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-18 17:19:15 -07:00
..
bitset.c ethtool: fix ethnl_bitmap32_not_zero() bit interval semantics 2026-05-12 18:45:13 -07:00
bitset.h net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
cabletest.c net: ethtool: optionally skip rtnl_lock in cable test handlers 2026-06-09 10:13:05 -07:00
channels.c net, ethtool: Disallow leased real rxqs to be resized 2026-04-09 18:21:46 -07:00
cmis_cdb.c net: ethtool: cmis_cdb: hold instance lock for ops locked devices 2026-06-04 14:04:55 -07:00
cmis_fw_update.c net: ethtool: cmis_cdb: hold instance lock for ops locked devices 2026-06-04 14:04:55 -07:00
cmis.h ethtool: cmis: fix u16-to-u8 truncation of msleep_pre_rpl 2026-05-26 08:19:33 -07:00
coalesce.c ethtool: coalesce: cap profile updates at NET_DIM_PARAMS_NUM_PROFILES 2026-05-27 17:42:07 -07:00
common.c tls: remove tls_toe and the related driver 2026-06-12 16:43:10 -07:00
common.h net: ethtool: keep rtnl_lock for the ioctl self test 2026-09-18 17:19:15 -07:00
debug.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
eee.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
eeprom.c ethtool: eeprom: add more safeties to EEPROM Netlink fallback 2026-05-27 17:42:09 -07:00
features.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
fec.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
ioctl.c net: ethtool: add KSZ87xx low-loss cable PHY tunables 2026-06-11 15:47:56 -07:00
linkinfo.c net: ethtool: add netif_get_link_ksettings() for correct ops-locked use 2026-06-04 14:04:55 -07:00
linkmodes.c net: ethtool: add netif_get_link_ksettings() for correct ops-locked use 2026-06-04 14:04:55 -07:00
linkstate.c ethtool: linkstate: fix unbalanced ethnl_ops_complete() on PHY lookup error 2026-05-27 17:42:08 -07:00
Makefile ethtool: netlink: add ETHTOOL_MSG_MSE_GET and wire up PHY MSE access 2025-11-03 18:32:27 -08:00
mm.c net: ethtool: optionally skip rtnl_lock on Netlink path for GET ops 2026-06-09 10:13:04 -07:00
module_fw.h ethtool: Add ability to flash transceiver modules' firmware 2024-06-28 10:48:23 +01:00
module.c net: ethtool: optionally skip rtnl_lock in ethnl_act_module_fw_flash() 2026-06-09 10:13:05 -07:00
mse.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
netlink.c net: ethtool: optionally skip rtnl_lock on Netlink path for SET ops 2026-06-09 10:13:05 -07:00
netlink.h ethtool: rss: Fix hfunc and input_xfrm parsing on big endian 2026-07-09 11:38:30 +02:00
pause.c net: ethtool: pass genl_info to the ethnl parse_request operation 2026-03-24 20:14:29 -07:00
phc_vclocks.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
phy.c net: ethtool: relax ethnl_req_get_phydev() locking assertion 2026-06-09 10:13:04 -07:00
plca.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
privflags.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
pse-pd.c ethtool: pse-pd: fix missing ethnl_ops_complete() 2026-05-27 17:42:08 -07:00
rings.c net: ethtool: fix missing closing paren in rings_reply_size() 2026-05-11 18:42:25 -07:00
rss.c ethtool: rss: Fix hfunc and input_xfrm parsing on big endian 2026-07-09 11:38:30 +02:00
stats.c net: ethtool: pass genl_info to the ethnl parse_request operation 2026-03-24 20:14:29 -07:00
strset.c ethtool: strset: fix header attribute index in ethnl_req_get_phydev() 2026-05-27 17:42:09 -07:00
ts.h net: ethtool: tsinfo: Enhance tsinfo to support several hwtstamp by net topology 2024-12-16 12:51:41 +00:00
tsconfig.c ethtool: tsconfig: reject zero-valued tx_type and rx_filter bitsets 2026-08-13 17:44:54 -07:00
tsinfo.c net: ethtool: optionally skip rtnl_lock in ethnl_tsinfo_dumpit() 2026-06-09 10:13:05 -07:00
tunnels.c genetlink: use attrs from struct genl_info 2023-08-15 15:00:45 -07:00
wol.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00