From: Russell King (Oracle) <hidden> Date: 2021-09-30 14:54:50
On the MDIO bus, we have PHYLIB devices and drivers, and we have non-
PHYLIB devices and drivers. PHYLIB devices are MDIO devices that are
wrapped with a struct phy_device.
Trying to bind a MDIO device with a PHYLIB driver results in out-of-
bounds accesses as we attempt to access struct phy_device members. So,
let's prevent this by ensuring that the type of the MDIO device
(indicated by the MDIO_DEVICE_FLAG_PHY flag) matches the type of the
MDIO driver (indicated by the MDIO_DEVICE_IS_PHY flag.)
Link: https://lore.kernel.org/r/2b1dc053-8c9a-e3e4-b450-eecdfca3fe16@gmail.com
Signed-off-by: Russell King (Oracle) <redacted>
---
Tested locally in SolidRun Clearfog, DSA switch and PHY get probed
correctly. Further testing welcomed.
drivers/net/phy/mdio_bus.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -939,6 +939,12 @@ EXPORT_SYMBOL_GPL(mdiobus_modify);staticintmdio_bus_match(structdevice*dev,structdevice_driver*drv){structmdio_device*mdio=to_mdio_device(dev);+structmdio_driver*mdiodrv=to_mdio_driver(drv);++/* Both the driver and device must type-match */+if(!(mdiodrv->mdiodrv.flags&MDIO_DEVICE_IS_PHY)!=+!(mdio->flags&MDIO_DEVICE_FLAG_PHY))+return0;if(of_driver_match_device(dev,drv))return1;
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-09-30 14:59:01
On Thu, Sep 30, 2021 at 03:54:44PM +0100, Russell King (Oracle) wrote:
quoted hunk
On the MDIO bus, we have PHYLIB devices and drivers, and we have non-
PHYLIB devices and drivers. PHYLIB devices are MDIO devices that are
wrapped with a struct phy_device.
Trying to bind a MDIO device with a PHYLIB driver results in out-of-
bounds accesses as we attempt to access struct phy_device members. So,
let's prevent this by ensuring that the type of the MDIO device
(indicated by the MDIO_DEVICE_FLAG_PHY flag) matches the type of the
MDIO driver (indicated by the MDIO_DEVICE_IS_PHY flag.)
Link: https://lore.kernel.org/r/2b1dc053-8c9a-e3e4-b450-eecdfca3fe16@gmail.com
Signed-off-by: Russell King (Oracle) <redacted>
---
Tested locally in SolidRun Clearfog, DSA switch and PHY get probed
correctly. Further testing welcomed.
drivers/net/phy/mdio_bus.c | 6 ++++++
1 file changed, 6 insertions(+)
From: "Russell King (Oracle)" <linux@armlinux.org.uk> Date: 2021-09-30 15:15:42
On Thu, Sep 30, 2021 at 04:58:53PM +0200, Andrew Lunn wrote:
On Thu, Sep 30, 2021 at 03:54:44PM +0100, Russell King (Oracle) wrote:
quoted
On the MDIO bus, we have PHYLIB devices and drivers, and we have non-
PHYLIB devices and drivers. PHYLIB devices are MDIO devices that are
wrapped with a struct phy_device.
Trying to bind a MDIO device with a PHYLIB driver results in out-of-
bounds accesses as we attempt to access struct phy_device members. So,
let's prevent this by ensuring that the type of the MDIO device
(indicated by the MDIO_DEVICE_FLAG_PHY flag) matches the type of the
MDIO driver (indicated by the MDIO_DEVICE_IS_PHY flag.)
Link: https://lore.kernel.org/r/2b1dc053-8c9a-e3e4-b450-eecdfca3fe16@gmail.com
Signed-off-by: Russell King (Oracle) <redacted>
---
Tested locally in SolidRun Clearfog, DSA switch and PHY get probed
correctly. Further testing welcomed.
drivers/net/phy/mdio_bus.c | 6 ++++++
1 file changed, 6 insertions(+)