Re: [PATCH net-next] net: ethtool: request rtnl_lock for ETHTOOL_MSG_PORT_GET
From: Linkui Xiao
Date: Sun Nov 15 2026 - 22:10:47 EST
- [High] The fix covers only one of several commands with the same bug.
Thanks for the review. The patch has been withdrawn following Stanislav's
review (patchwork already shows it rejected), so there is no respin and no
"pw-bot: cr" to send. On the substance, the observation about the call
sites is accurate - STRSET, LINKSTATE, STATS, PHY, PLCA, PSE, MSE and the
cable test handlers all resolve their PHY through ethnl_req_get_phydev() -
but the conclusion does not follow, because the device this issue asks us
to consider - ops-locked, with a non-NULL dev->link_topo - cannot exist.
dev->link_topo is only ever allocated by phy_link_topo_get_or_alloc(),
whose only callers are phy_link_topo_add_port() and
phy_link_topo_add_phy(). Both refuse an ops-locked device before they
allocate anything:
if (WARN_ON_ONCE(dev->netdev_ops && netdev_need_ops_lock(dev)))
return -EOPNOTSUPP; /* add_port() */
if (WARN_ON_ONCE(netdev_need_ops_lock(dev)))
return -EOPNOTSUPP; /* add_phy() */
So on an ops-locked device dev->link_topo is always NULL, and every
topology reader bails out before its assert:
- phy_link_topo_get_port() returns at its !topo check, before
ASSERT_RTNL();
- phy_link_topo_empty() is simply "return !dev->link_topo", so
ethnl_req_get_phydev() skips its assert and never touches topo->phys;
- the cable test handlers resolve their PHY through
ethnl_req_get_phydev() too, so they hit the same skip.
The drivers that opt into the instance lock (request_ops_lock,
queue_mgmt_ops, net_shaper_ops) all do so before registration, so there
is no path that grows a topology first and becomes ops-locked later
either. If an ops-locked device ever grows phy_ports, the right fix is
to move the topology readers under the instance lock, as the comments at
the producers already anticipate - not to add a rtnl case per command.
Regards,
Linkui