Patch "phy: phy_ethtool_ksettings_set: Lock the PHY while changing settings" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    phy: phy_ethtool_ksettings_set: Lock the PHY while changing settings

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     phy-phy_ethtool_ksettings_set-lock-the-phy-while-changing-settings.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From af1a02aa23c37045e6adfcf074cf7dbac167a403 Mon Sep 17 00:00:00 2001
From: Andrew Lunn <andrew@xxxxxxx>
Date: Sun, 24 Oct 2021 21:48:05 +0200
Subject: phy: phy_ethtool_ksettings_set: Lock the PHY while changing settings

From: Andrew Lunn <andrew@xxxxxxx>

commit af1a02aa23c37045e6adfcf074cf7dbac167a403 upstream.

There is a race condition where the PHY state machine can change
members of the phydev structure at the same time userspace requests a
change via ethtool. To prevent this, have phy_ethtool_ksettings_set
take the PHY lock.

Fixes: 2d55173e71b0 ("phy: add generic function to support ksetting support")
Reported-by: Walter Stoll <Walter.Stoll@xxxxxxxxxx>
Suggested-by: Walter Stoll <Walter.Stoll@xxxxxxxxxx>
Tested-by: Walter Stoll <Walter.Stoll@xxxxxxxxxx>
Signed-off-by: Andrew Lunn <andrew@xxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/net/phy/phy.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -814,6 +814,7 @@ int phy_ethtool_ksettings_set(struct phy
 	      duplex != DUPLEX_FULL)))
 		return -EINVAL;
 
+	mutex_lock(&phydev->lock);
 	phydev->autoneg = autoneg;
 
 	if (autoneg == AUTONEG_DISABLE) {
@@ -830,8 +831,9 @@ int phy_ethtool_ksettings_set(struct phy
 	phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;
 
 	/* Restart the PHY */
-	phy_start_aneg(phydev);
+	_phy_start_aneg(phydev);
 
+	mutex_unlock(&phydev->lock);
 	return 0;
 }
 EXPORT_SYMBOL(phy_ethtool_ksettings_set);


Patches currently in stable-queue which might be from andrew@xxxxxxx are

queue-5.10/phy-phy_ethtool_ksettings_get-lock-the-phy-for-consistency.patch
queue-5.10/phy-phy_ethtool_ksettings_set-move-after-phy_start_aneg.patch
queue-5.10/phy-phy_start_aneg-add-an-unlocked-version.patch
queue-5.10/arm64-dts-allwinner-h5-nanopi-neo-2-fix-ethernet-node.patch
queue-5.10/phy-phy_ethtool_ksettings_set-lock-the-phy-while-changing-settings.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux