netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net: usb: asix: validate PHY address before use
@ 2025-12-18  1:11 Deepanshu Kartikey
  2025-12-18 10:17 ` Andrew Lunn
  2025-12-28  8:31 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Deepanshu Kartikey @ 2025-12-18  1:11 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, khalasa,
	andriy.shevchenko
  Cc: o.rempel, linux-usb, netdev, linux-kernel, Deepanshu Kartikey,
	syzbot+3d43c9066a5b54902232

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/ [v1]
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
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(-)

diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index 7fd763917ae2..6ab3486072cb 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -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);
 
diff --git a/drivers/net/usb/ax88172a.c b/drivers/net/usb/ax88172a.c
index f613e4bc68c8..758a423a459b 100644
--- a/drivers/net/usb/ax88172a.c
+++ b/drivers/net/usb/ax88172a.c
@@ -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);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] net: usb: asix: validate PHY address before use
  2025-12-18  1:11 [PATCH v2] net: usb: asix: validate PHY address before use Deepanshu Kartikey
@ 2025-12-18 10:17 ` Andrew Lunn
  2025-12-28  8:31 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2025-12-18 10:17 UTC (permalink / raw)
  To: Deepanshu Kartikey
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, khalasa,
	andriy.shevchenko, o.rempel, linux-usb, netdev, linux-kernel,
	syzbot+3d43c9066a5b54902232

On Thu, Dec 18, 2025 at 06:41:56AM +0530, Deepanshu Kartikey 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 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/ [v1]
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] net: usb: asix: validate PHY address before use
  2025-12-18  1:11 [PATCH v2] net: usb: asix: validate PHY address before use Deepanshu Kartikey
  2025-12-18 10:17 ` Andrew Lunn
@ 2025-12-28  8:31 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-12-28  8:31 UTC (permalink / raw)
  To: Deepanshu Kartikey
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, khalasa,
	andriy.shevchenko, o.rempel, linux-usb, netdev, linux-kernel,
	syzbot+3d43c9066a5b54902232

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

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 in
> mdiobus_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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-28  8:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-18  1:11 [PATCH v2] net: usb: asix: validate PHY address before use Deepanshu Kartikey
2025-12-18 10:17 ` Andrew Lunn
2025-12-28  8:31 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).