mbox series

[net,0/4] ksettings_{get|set} lock fixes

Message ID 20211024194805.2762333-1-andrew@lunn.ch (mailing list archive)
Headers show
Series ksettings_{get|set} lock fixes | expand

Message

Andrew Lunn Oct. 24, 2021, 7:48 p.m. UTC
Walter Stoll <Walter.Stoll@duagon.com> reported a race condition
between "ethtool -s eth0 speed 100 duplex full autoneg off" and phylib
reading the current status from the PHY. Both ksetting_get and
ksetting_set fail the take the phydev mutex, and as a result, there is
a small window of time where the phydev members are not self
consistent.

Patch 1 fixes phy_ethtool_ksettings_get by adding the needed lock.
Patches 2 and 3 move code around and perform to refactoring, to allow
patch 4 to fix phy_ethtool_ksettings_set by added the lock.

Thanks go to Walter for the detailed origional report, suggested fix,
and testing of the proposed patches.

Andrew Lunn (4):
  phy: phy_ethtool_ksettings_get: Lock the phy for consistency
  phy: phy_ethtool_ksettings_set: Move after phy_start_aneg
  phy: phy_start_aneg: Add an unlocked version
  phy: phy_ethtool_ksettings_set: Lock the PHY while changing settings

 drivers/net/phy/phy.c | 140 ++++++++++++++++++++++++------------------
 1 file changed, 81 insertions(+), 59 deletions(-)