Linux USB
 help / color / mirror / Atom feed
* [PATCH v8 0/4] usb: gadget: f_tcm: fix infoleaks, sleep, and UAF in the BOT path
@ 2026-11-18 12:40 Yehyeong Lee
  2026-11-18 12:40 ` [PATCH v8 1/4] usb: gadget: f_tcm: queue the BOT status requests with GFP_ATOMIC Yehyeong Lee
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Yehyeong Lee @ 2026-11-18 12:40 UTC (permalink / raw)
  To: gregkh, nkapron, linux-usb
  Cc: Thinh.Nguyen, bigeasy, target-devel, linux-kernel, benquike

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

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-18 12:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 12:40 [PATCH v8 0/4] usb: gadget: f_tcm: fix infoleaks, sleep, and UAF in the BOT path Yehyeong Lee
2026-11-18 12:40 ` [PATCH v8 1/4] usb: gadget: f_tcm: queue the BOT status requests with GFP_ATOMIC Yehyeong Lee
2026-11-18 12:43   ` sashiko-bot
2026-11-18 12:40 ` [PATCH v8 2/4] usb: gadget: f_tcm: zero the CBW buffer the status path sends Yehyeong Lee
2026-11-18 12:45   ` sashiko-bot
2026-11-18 12:40 ` [PATCH v8 3/4] usb: gadget: f_tcm: reject a short write data-out transfer Yehyeong Lee
2026-11-18 12:59   ` sashiko-bot
2026-11-18 12:40 ` [PATCH v8 4/4] usb: gadget: f_tcm: clear the scatter list when reusing the BOT status request Yehyeong Lee
2026-11-18 12:46   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox