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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1430359064-23454-3-git-send-email-f.fainelli@gmail.com>
Date:	Wed, 29 Apr 2015 18:57:38 -0700
From:	Florian Fainelli <f.fainelli@...il.com>
To:	netdev@...r.kernel.org
Cc:	dave@...emloft.net, Florian Fainelli <f.fainelli@...il.com>,
	vivien.didelot@...oirfairelinux.com,
	jerome.oufella@...oirfairelinux.com, linux@...ck-us.net,
	andrew@...n.ch, cphealy@...il.com, mathieu@...eaurora.org,
	jonasj76@...il.com, andrey.volkov@...vision.fr,
	Chris.Packham@...iedtelesis.co.nz
Subject: [RFC PATCH net-next 2/8] net: phy: Check fixup lists in get_phy_device()

MDIO-connected Ethernet switches will typicall appear as regular
Ethernet PHYs on the MDIO bus, except that they will be accessed using
their unique pseudo-PHY address (16 for Marvell, 30 for Broadcom etc...)
and reading standard MII registers such as MII_PHYSID1 and MII_PHYSID2
from this pseudo-PHY address will not yield expected results.

This is expected because the pseudo-PHY is a special port of the switch
to access internal registers.

PHY drivers will typically intercept these reads by registering a fixup,
checking that the fixup should only apply to the PHY address at the
pseudo-PHY location, and return the expected 32-bits unique OUI of the
switch when reads to that address are performed.

This currently does not work when probed from Device Tree since we
end-up calling get_phy_device() from drivers/of/of_mdio.c, read, e.g: all
F's and decide there is no such PHY there.

A simple fix to that problem is to verify that the fixup list for that
PHY is not empty, if not then we just allow the PHY device creation
since that means a corresponding driver is intending to fixup reads of
the PHY id.

Signed-off-by: Florian Fainelli <f.fainelli@...il.com>
---
 drivers/net/phy/phy_device.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index bdfe51fc3a65..8efc4b8ffc59 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -333,8 +333,13 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
 	if (r)
 		return ERR_PTR(r);
 
-	/* If the phy_id is mostly Fs, there is no device there */
-	if ((phy_id & 0x1fffffff) == 0x1fffffff)
+	/* If the phy_id is mostly Fs and we have no fixups registered which
+	 * could alter how phydev->phy_id is going to be read,
+	 * there is no device there */
+	mutex_lock(&phy_fixup_lock);
+	r = ((phy_id & 0x1fffffff) == 0x1fffffff) && list_empty(&phy_fixup_list);
+	mutex_unlock(&phy_fixup_lock);
+	if (r)
 		return NULL;
 
 	return phy_device_create(bus, addr, phy_id, is_c45, &c45_ids);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ