[PATCH net 0/4] ksettings_{get|set} lock fixes
From: Andrew Lunn <andrew@lunn.ch>
Date: 2021-10-24 19:48:31
Walter Stoll [off-list ref] 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(-) -- 2.33.0