From: Andi Shyti <andi.shyti@kernel.org>
To: "HE WEI (ギカク)" <skyexpoc@gmail.com>
Cc: Hans de Goede <hansg@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-usb@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2 1/3] usb: misc: usbio: reject endpoints smaller than the packet header
Date: Wed, 29 Jul 2026 23:16:32 +0200 [thread overview]
Message-ID: <ampsSryj3Vtjo37H@zenone.zhora.eu> (raw)
In-Reply-To: <20260726113511.57596-2-skyexpoc@gmail.com>
Hi He Wei,
On Sun, Jul 26, 2026 at 08:35:07PM +0900, HE WEI (ギカク) wrote:
> usbio_ctrl_msg() and usbio_bulk_msg() bound the caller's transfer sizes
> against the endpoint packet size minus the fixed protocol header:
>
> if ((obuf_len > (usbio->txbuf_len - sizeof(*bpkt))) ||
> (ibuf_len > (usbio->txbuf_len - sizeof(*bpkt))))
> return -EMSGSIZE;
>
> usbio->txbuf_len is a u16 and sizeof(*bpkt) is a size_t, so the
> subtraction is done in size_t. struct usbio_bulk_packet is 5 bytes and
... blah blah blah ...
> via usbio_i2c_init() with obuf_len = 7. The wrapped check passes and the
> packet header stores overflow the slab object before memcpy() is even
> reached:
>
> bpkt = usbio->txbuf;
> bpkt->header.type = type; /* txbuf[0] */
> bpkt->header.cmd = cmd; /* txbuf[1], out of bounds */
> bpkt->header.flags = ...; /* txbuf[2], out of bounds */
> bpkt->len = cpu_to_le16(obuf_len); /* txbuf[3..4] */
> memcpy(bpkt->data, obuf, obuf_len); /* txbuf[5..] */
>
> Note that this is all complete before usb_bulk_msg() is called, so it
> does not depend on the host controller being willing to run a transfer
> on such an endpoint. With KASAN it is a slab-out-of-bounds write.
... blah blah blah ...
> combined with "(udev->speed >= USB_SPEED_SUPER && i > 0)" below, so
> bMaxPacketSize0 of 0 or 1 gives a ctrlbuf of 1 or 2 bytes and the same
> wrap, during the five usbio_ctrl_msg() calls in usbio_probe(). Whether
> a given host controller will operate such an ep0 has not been
... blah blah blah ...
> Found by code review, doing variant analysis on the code around
> 8c6314489550. The overflow was reproduced under AddressSanitizer with a
> userspace model of usbio_probe() and usbio_bulk_msg() that uses this
> driver's struct definitions, checks and stores verbatim; it has not been
> exercised on hardware or on dummy_hcd.
>
> Fixes: 121a0f839dbb ("usb: misc: Add Intel USBIO bridge driver")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-5 asan
> Signed-off-by: HE WEI (ギカク) <skyexpoc@gmail.com>
Please use Latin characters, with the first letter of each name
capitalized: "He Wei", not "HE WEI".
Also, your commit logs are far too long. If I had to spend this
much time reading AI generated commit logs, I'd end up spending
all my time chatting with AI instead of real people.
Please check what you are posting before sending it. Write the
commit logs yourself and use AI only to help with the grammar.
Thanks,
Andi
next prev parent reply other threads:[~2026-07-29 21:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-26 11:35 [PATCH v2 0/3] usbio: fix two out-of-bounds accesses and a hang HE WEI (ギカク)
2026-07-26 11:35 ` [PATCH v2 1/3] usb: misc: usbio: reject endpoints smaller than the packet header HE WEI (ギカク)
2026-07-26 11:41 ` Greg Kroah-Hartman
2026-07-29 21:16 ` Andi Shyti [this message]
2026-08-02 8:43 ` Greg Kroah-Hartman
2026-07-26 11:35 ` [PATCH v2 2/3] i2c: usbio: reject bridges with undersized transfer buffers HE WEI (ギカク)
2026-07-26 11:35 ` [PATCH v2 3/3] usb: misc: usbio: bound the debug hex dumps by the received length HE WEI (ギカク)
2026-08-02 8:44 ` Greg Kroah-Hartman
2026-08-02 8:53 ` HE WEI(ギカク)
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=ampsSryj3Vtjo37H@zenone.zhora.eu \
--to=andi.shyti@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=skyexpoc@gmail.com \
--cc=stable@vger.kernel.org \
/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