intel-wired-lan.osuosl.org archive mirror
 help / color / mirror / Atom feed
From: rivaldihormat-debug <rivaldihormat@gmail.com>
To: intel-wired-lan@lists.osuosl.org
Cc: linux-kernel@vger.kernel.org,
	rivaldihormat-debug <rivaldihormat@gmail.com>,
	rivaldihormat-debug <rivaldihormat@example.com>
Subject: [PATCH] usb: core: devio: add defensive bounds check for len2 in do_proc_bulk()
Date: Fri,  4 Sep 2026 06:25:54 +0000	[thread overview]
Message-ID: <20260904062554.18628-2-rivaldihormat@gmail.com> (raw)
In-Reply-To: <20260904062554.18628-1-rivaldihormat@gmail.com>

Although the USB host controller hardware prevents len2 from exceeding
len1 in normal operation via babble error handling, add an explicit
kernel-side check to improve robustness. This helps prevent unexpected
behavior in virtualized environments where emulation bugs might break
this guarantee.

Clamp len2 to len1 if it exceeds the allocated buffer size and log
a warning message.

Signed-off-by: rivaldihormat-debug <rivaldihormat@example.com>
---
 drivers/usb/core/devio.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 101cb9425480..9d8930853e8f 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1343,6 +1343,10 @@ static int do_proc_bulk(struct usb_dev_state *ps,
 		snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, tbuf, len2);
 
 		if (!i && len2) {
+                        if (len2 > len1) {
+                                dev_warn(&dev->dev, "USB returned more data than expected\n");
+                                len2 = len1;
+                        }
 			if (copy_to_user(bulk->data, tbuf, len2)) {
 				ret = -EFAULT;
 				goto done;
-- 
2.53.0


  reply	other threads:[~2026-09-04 15:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  6:25 [PATCH] i40e: fix integer overflow in i40e_dbg_command_write() rivaldihormat-debug
2026-09-04  6:25 ` rivaldihormat-debug [this message]
2026-09-05 14:31 ` Paul Menzel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260904062554.18628-2-rivaldihormat@gmail.com \
    --to=rivaldihormat@gmail.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rivaldihormat@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).