Skip to content

Commit 24ef2f5

Browse files
Yuichiro Tsujikuba-moo
authored andcommitted
net: usb: asix_devices: Fix PHY address mask in MDIO bus initialization
Syzbot reported shift-out-of-bounds exception on MDIO bus initialization. The PHY address should be masked to 5 bits (0-31). Without this mask, invalid PHY addresses could be used, potentially causing issues with MDIO bus operations. Fix this by masking the PHY address with 0x1f (31 decimal) to ensure it stays within the valid range. Fixes: 4faff70 ("net: usb: asix_devices: add phy_mask for ax88772 mdio bus") Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=20537064367a0f98d597 Tested-by: [email protected] Signed-off-by: Yuichiro Tsuji <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent bc1a59c commit 24ef2f5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/usb/asix_devices.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ static int ax88772_init_mdio(struct usbnet *dev)
676676
priv->mdio->read = &asix_mdio_bus_read;
677677
priv->mdio->write = &asix_mdio_bus_write;
678678
priv->mdio->name = "Asix MDIO Bus";
679-
priv->mdio->phy_mask = ~(BIT(priv->phy_addr) | BIT(AX_EMBD_PHY_ADDR));
679+
priv->mdio->phy_mask = ~(BIT(priv->phy_addr & 0x1f) | BIT(AX_EMBD_PHY_ADDR));
680680
/* mii bus name is usb-<usb bus number>-<usb device number> */
681681
snprintf(priv->mdio->id, MII_BUS_ID_SIZE, "usb-%03d:%03d",
682682
dev->udev->bus->busnum, dev->udev->devnum);

0 commit comments

Comments
 (0)