]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: usb: asix: validate PHY address before use
authorDeepanshu Kartikey <kartikey406@gmail.com>
Thu, 18 Dec 2025 01:11:56 +0000 (06:41 +0530)
committerPaolo Abeni <pabeni@redhat.com>
Sun, 28 Dec 2025 08:05:12 +0000 (09:05 +0100)
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.

Reported-by: syzbot+3d43c9066a5b54902232@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=3d43c9066a5b54902232
Tested-by: syzbot+3d43c9066a5b54902232@syzkaller.appspotmail.com
Fixes: 7e88b11a862a ("net: usb: asix: refactor asix_read_phy_addr() and handle errors on return")
Link: https://lore.kernel.org/all/20251217085057.270704-1-kartikey406@gmail.com/T/
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20251218011156.276824-1-kartikey406@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/usb/asix_common.c
drivers/net/usb/ax88172a.c

index 7fd763917ae2cf6f4242a054416130ba820c8c73..6ab3486072cb0f5edd182644e084a8a05c97ec94 100644 (file)
@@ -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);
 
index f613e4bc68c8512a1186b8c5d240e7d1aab0b730..758a423a459b80758f62f608daab84f3827522ac 100644 (file)
@@ -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);