Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: usb: mcs7830: skip zero-length register dump reads
@ 2026-11-25  7:16 YuanZhe Liu
  2026-11-25  7:23 ` netdev-bot+sinfo
  0 siblings, 1 reply; 3+ messages in thread
From: YuanZhe Liu @ 2026-11-25  7:16 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: linux-usb, netdev, linux-kernel, stable, Bin Yu, Cheng Wen

mcs7830_get_regs() passes the user-supplied regs->len straight to
mcs7830_get_reg(), which submits a vendor control-IN request for that
many bytes.  ETHTOOL_GREGS accepts a zero length, and ethtool_get_regs()
still invokes the driver's get_regs() callback in that case, so a
zero-byte dump request reaches the driver.

A zero-length USB transfer has no data stage and the USB core treats it
as an OUT transfer, so submitting it on usb_rcvctrlpipe() triggers

  usb 1-1: BOGUS control dir, pipe 80000380 doesn't match bRequestType c0
  WARNING: drivers/usb/core/urb.c:411 at usb_submit_urb

and taints the kernel, which becomes a denial of service when
panic_on_warn is set.

There is nothing to read when regs->len is zero, so return early before
issuing the transfer.

Fixes: 2a36d7083438 ("USB: driver for mcs7830 (aka DeLOCK) USB ethernet adapter")
Cc: stable@vger.kernel.org
Co-developed-by: Bin Yu <byu@xidian.edu.cn>
Signed-off-by: Bin Yu <byu@xidian.edu.cn>
Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
---
 drivers/net/usb/mcs7830.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index d6698f30218d..f5606f2cea05 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -437,6 +437,8 @@ static void mcs7830_get_regs(struct net_device *net, struct ethtool_regs *regs,
 	struct usbnet *dev = netdev_priv(net);
 
 	regs->version = mcs7830_get_rev(dev);
+	if (!regs->len)
+		return;
 	mcs7830_get_reg(dev, 0, regs->len, data);
 }
 
-- 
2.34.1


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

end of thread, other threads:[~2026-11-25  7:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  7:16 [PATCH] net: usb: mcs7830: skip zero-length register dump reads YuanZhe Liu
2026-11-25  7:23 ` netdev-bot+sinfo
2026-11-25  7:32   ` YuanZhe Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox