[PATCH v8 0/4] usb: gadget: f_tcm: fix infoleaks, sleep, and UAF in the BOT path

From: Yehyeong Lee

Date: Wed Nov 18 2026 - 07:40:30 EST


v7 was three patches, posted 2026-10-13 and not applied:
https://lore.kernel.org/all/20261013073328.2936318-1-yhlee@xxxxxxxxxxxxxxxxxx/

Changes since v7: a new 2/4 for a second infoleak in the same BOT status
path, a measurement added to 3/4, and the recipient list corrected - v7
left out the gadget maintainer. The other three are unchanged, on
7.4-rc3, where the file is byte for byte what v7 was written against.

1/4 queues the two BOT status requests that run from endpoint completion
callbacks with GFP_ATOMIC instead of GFP_KERNEL.

2/4 allocates the CBW buffer with kzalloc(). Only the 31-byte CBW is
ever written into it, and when a command is rejected before its data
stage the status path sends that buffer to the host for as long a
transfer as the host asked for.

3/4 fails a write whose data stage delivered less than the CBW declared,
instead of committing the untouched tail of the bounce buffer. 4/4
clears req->sg and req->num_sgs when the BOT status request is reused, so
an sg-capable controller is not handed a freed scatter list.

Measured on a dummy_hcd gadget with KASAN, one fresh boot per cell, two
cells per arm, speaking BOT over usbfs so a CBW can declare one length
and the data stage deliver another.

WRITE(10) declaring 8192, 4000 delivered on a short packet
7.4-rc3 CSW status 0, and 4192 bytes the host never sent are
committed and read back
this set CSW status 1, nothing committed
a rejected IN command declaring 4096 bytes
both 4096 bytes returned, 72 of them non-zero and the rest
zero, starting with the previous CBW. What 2/4 removes
is the part of the buffer no CBW ever writes, and that
part read back zero on this allocator too, so the patch
does not change what this test sees.
login, read, write, readback controls pass on both, KASAN 0

1/4 and 4/4 are not exercised there: dummy_hcd ignores the gfp flags in
its queue callback and never sets sg_supported. 4/4's evidence is a test
module standing in for an sg-capable controller; 1/4's is the code.

Yehyeong Lee (4):
usb: gadget: f_tcm: queue the BOT status requests with GFP_ATOMIC
usb: gadget: f_tcm: zero the CBW buffer the status path sends
usb: gadget: f_tcm: reject a short write data-out transfer
usb: gadget: f_tcm: clear the scatter list when reusing the BOT status
request

drivers/usb/gadget/function/f_tcm.c | 23 +++++++++++++++++------
drivers/usb/gadget/function/tcm.h | 1 +
2 files changed, 18 insertions(+), 6 deletions(-)

--
2.43.0