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

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

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

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

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

Hi,

The issue was found during testing of the driver's ethtool register dump
path, not in production or from a bug report.  A bound MCS7830 interface
and CAP_NET_ADMIN are enough: requesting a zero-length register dump
(ETHTOOL_GREGS with regs.len = 0) reaches mcs7830_get_regs() and makes it
submit the zero-length vendor control-IN request that triggers the
warning.  It reproduces every time the ioctl is issued with len = 0.

Thanks,
YuanZhe Liu


^ permalink raw reply	[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