net: usb: asix: validate PHY address before use
Subsystems (4)
PATCH v2 1/1 net: usb: asix: validate PHY address before use
The ASIX driver reads the PHY address from the USB device via asix_read_phy_addr(). A malicious or faulty device can return an invalid address (>= PHY_MAX_ADDR), which causes a warning in mdiobus_get_phy():
addr 207 out of range
WARNING: drivers/net/phy/mdio_bus.c:76
Validate the PHY address in asix_read_phy_addr() and remove the now-redundant check in ax88172a.c.
---
v2:
- Remove redundant validation check in ax88172a.c (Andrew Lunn)
--- drivers/net/usb/asix_common.c | 5 +++++ drivers/net/usb/ax88172a.c | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/usb/asix_common.c +5 -0
@@ -335,6 +335,11 @@ int asix_read_phy_addr(struct usbnet *dev, bool internal) offset = (internal ?1 :0 ); ret = buf[offset]; +if (ret >=PHY_MAX_ADDR ) { +netdev_err (dev->net,"invalid PHY address: %d\n" , ret); +return -ENODEV ; + } +netdev_dbg (dev->net,"%s PHY address 0x%x\n" , internal ?"internal" :"external" , ret);
drivers/net/usb/ax88172a.c +1 -5
@@ -210,11 +210,7 @@ static int ax88172a_bind(struct usbnet *dev, struct usb_interface *intf) ret =asix_read_phy_addr (dev, priv->use_embdphy);if (ret <0 ) goto free; -if (ret >=PHY_MAX_ADDR ) { -netdev_err (dev->net,"Invalid PHY address %#x\n" , ret); - ret = -ENODEV ; - goto free; - } + priv->phy_addr = ret;ax88172a_reset_phy (dev, priv->use_embdphy);
Signature · 1 line
2.43.0
Quoted 11 lines · Deepanshu Kartikey
The ASIX driver reads the PHY address from the USB device via
asix_read_phy_addr(). A malicious or faulty device can return an invalid address (>=PHY_MAX_ADDR), which causes a warning inmdiobus_get_phy():addr 207 out of range
WARNING: drivers/net/phy/mdio_bus.c:76Validate the PHY address in
asix_read_phy_addr()and remove the now-redundant check inax88172a.c.
Quoted 6 lines
Reported-by [email protected]Tested-by [email protected]Fixes 7e88b11a862a ("net: usb: asix: refactor asix_read_phy_addr() and handle errors on return")Signed-off-by Deepanshu Kartikey <[email protected]>
Andrew
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 9 lines · On Thu, 18 Dec 2025 06:41:56 +0530 you wrote:
The ASIX driver reads the PHY address from the USB device via
asix_read_phy_addr(). A malicious or faulty device can return an invalid address (>=PHY_MAX_ADDR), which causes a warning inmdiobus_get_phy():addr 207 out of range
WARNING: drivers/net/phy/mdio_bus.c:76[...]
Here is the summary with links:
- [v2] net: usb: asix: validate PHY address before use
https://git.kernel.org/netdev/net/c/a1e077a3f76e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html