Re: [PATCH v2 1/3] usb: misc: usbio: reject endpoints smaller than the packet header

From: Andi Shyti

Date: Wed Jul 29 2026 - 17:17:27 EST


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@xxxxxxxxxxxxxxx
> Assisted-by: Claude:claude-opus-5 asan
> Signed-off-by: HE WEI (ギカク) <skyexpoc@xxxxxxxxx>

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