From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: rivaldihormat-debug <rivaldihormat@gmail.com>
Cc: linux-usb@vger.kernel.org,
rivaldihormat-debug <rivaldihormat@example.com>
Subject: Re: [PATCH] usb: core: devio: add defensive bounds check for len2 in do_proc_bulk()
Date: Fri, 4 Sep 2026 08:48:40 +0200 [thread overview]
Message-ID: <2026090449-skinning-cactus-6b2c@gregkh> (raw)
In-Reply-To: <20260904062958.19404-1-rivaldihormat@gmail.com>
On Fri, Sep 04, 2026 at 06:29:58AM +0000, rivaldihormat-debug wrote:
> 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.
Then that emulation environment is very very broken, please fix that.
> Clamp len2 to len1 if it exceeds the allocated buffer size and log
> a warning message.
>
> Signed-off-by: rivaldihormat-debug <rivaldihormat@example.com>
Not a valid name to use here :(
> ---
> 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;
This isn't even a good way to handle this error if it happened :(
next prev parent reply other threads:[~2026-09-04 6:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 6:29 [PATCH] usb: core: devio: add defensive bounds check for len2 in do_proc_bulk() rivaldihormat-debug
2026-09-04 6:48 ` Greg Kroah-Hartman [this message]
2026-09-04 16:37 ` Alan Stern
-- strict thread matches above, loose matches on Subject: below --
2026-09-04 6:39 [PATCH] i40e: fix integer overflow in i40e_dbg_command_write() rivaldihormat-debug
2026-09-04 6:39 ` [PATCH] usb: core: devio: add defensive bounds check for len2 in do_proc_bulk() rivaldihormat-debug
2026-09-04 6:47 ` Greg Kroah-Hartman
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=2026090449-skinning-cactus-6b2c@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=rivaldihormat@example.com \
--cc=rivaldihormat@gmail.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