From: Greg KH <gregkh@linuxfoundation.org>
To: Reid D <skibletz@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: usb: devio: USBFS_XFER_MAX check bypassed for iso urbs due to incorrect ordering, potential oob heap write
Date: Thu, 15 Oct 2026 07:18:10 +0200 [thread overview]
Message-ID: <2026101531-secular-entire-f7a4@gregkh> (raw)
In-Reply-To: <CAGNJ+_3qpWtzjTLntxTzF2v0jU9mVssukGfhrJFOx_yb+2Abyg@mail.gmail.com>
On Wed, Oct 14, 2026 at 05:36:56PM -0400, Reid D wrote:
> usb: devio: USBFS_XFER_MAX check bypassed for iso urbs
> due to incorrect ordering, potential oob heap write
>
> file: drivers/usb/core/devio.c
> function: proc_do_submiturb()
> ioctl: USBDEVFS_SUBMITURB
>
> the bug:
>
> the size check at line 1647 runs on buffer_length before the iso
> path has computed totlen. the iso path then overwrites buffer_length
> with totlen at line 1768, so the check never actually validates
> the real transfer size.
>
> line 1647 - check runs here on the wrong value:
> if ((unsigned int)uurb->buffer_length >= USBFS_XFER_MAX)
> return -EINVAL;
>
> line 1768 - real value computed after the check:
> uurb->buffer_length = totlen;
>
> line 1843 - kmalloc uses the unchecked value:
> as->urb->transfer_buffer = kmalloc(uurb->buffer_length, ...);
>
> impact:
>
> if totlen exceeds the kmalloc allocation size, the copy_from_user
> that follows writes past the end of the heap buffer. for an out
> transfer the user controls both the length and the data, giving a
> heap write-what-where primitive.
>
> current constants (128 packets * 98304 max each = 12mb) keep
> totlen below USBFS_XFER_MAX (16mb) so this is not exploitable
> today. the check ordering is structurally wrong regardless and
> will become a live bug if those constants change.
>
> fix:
>
> uurb->buffer_length = totlen;
> if (uurb->buffer_length >= USBFS_XFER_MAX)
> return -EINVAL;
>
Great, please turn this into a real patch that can be applied so you get
full credit for resolving this. Your favorite llm can easily do this
for you (and it can test it, which you really should also do...)
thanks,
greg k-h
next parent reply other threads:[~2026-10-15 5:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAGNJ+_3qpWtzjTLntxTzF2v0jU9mVssukGfhrJFOx_yb+2Abyg@mail.gmail.com>
2026-10-15 5:18 ` Greg KH [this message]
[not found] ` <CAGNJ+_0ShEM-G+8p3oHx1uF8rBtC7JyqmyFzswDB50qsW=qwuw@mail.gmail.com>
[not found] ` <2026101509-reggae-whacking-6598@gregkh>
2026-10-15 12:07 ` usb: devio: USBFS_XFER_MAX check bypassed for iso urbs due to incorrect ordering, potential oob heap write Reid D
2026-10-15 12:32 ` Greg KH
2026-10-15 14:54 ` Alan Stern
2026-10-15 15:26 ` Greg KH
2026-10-15 15:36 ` Alan Stern
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=2026101531-secular-entire-f7a4@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=skibletz@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