lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <m3plmhhx6d.fsf@t19.piap.pl>
Date: Wed, 27 Nov 2024 09:56:42 +0100
From: Krzysztof Hałasa <khalasa@...p.pl>
To: netdev <netdev@...r.kernel.org>
Cc: Oliver Neukum <oneukum@...e.com>, Andrew Lunn <andrew+netdev@...n.ch>,
 "David S. Miller" <davem@...emloft.net>, Eric
 Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo
 Abeni <pabeni@...hat.com>, linux-usb@...r.kernel.org,
 linux-kernel@...r.kernel.org, Jose Ignacio Tornos Martinez
 <jtornosm@...hat.com>, Ming Lei <ming.lei@...hat.com> 
Subject: [PATCH] PHY: Fix no autoneg corner case

phydev->autoneg appears to indicate if autonegotiation is enabled or
not. Unfortunately it's initially set based on the supported capability
rather than the actual hw setting. While in most cases there is no
difference (i.e., autoneg is supported and on by default), certain
adapters (e.g. fiber optics) use fixed settings, configured in hardware.

Now autoneg flag is set only when it's supported and actually used.

Signed-off-by: Krzysztof Hałasa <khalasa@...p.pl>

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 366cf3b2cbb0..6858f512558b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3453,7 +3453,7 @@ static int phy_probe(struct device *dev)
 	struct phy_device *phydev = to_phy_device(dev);
 	struct device_driver *drv = phydev->mdio.dev.driver;
 	struct phy_driver *phydrv = to_phy_driver(drv);
-	int err = 0;
+	int err = 0, bmcr;
 
 	phydev->drv = phydrv;
 
@@ -3495,8 +3495,12 @@ static int phy_probe(struct device *dev)
 	if (err)
 		goto out;
 
+	err = bmcr = phy_read(phydev, MII_BMCR);
+	if (err < 0)
+		goto out;
+
 	if (!linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
-			       phydev->supported))
+			       phydev->supported) || !(bmcr & BMCR_ANENABLE))
 		phydev->autoneg = 0;
 
 	if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,

-- 
Krzysztof "Chris" Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP
Al. Jerozolimskie 202, 02-486 Warszawa

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ