[PATCH v7 0/3] usb: gadget: f_tcm: fix infoleak, sleep, and UAF in the BOT completion path

From: Yehyeong Lee

Date: Tue Oct 13 2026 - 03:37:44 EST


Three fixes in the f_tcm BOT completion path, all reachable from a remote
USB host.

Patch 1 queues the status requests with GFP_ATOMIC: bot_send_bad_status()
and bot_send_status() run from endpoint completion callbacks, which are
called with interrupts disabled.

Patch 2 rejects a short write data-out transfer, which otherwise commits
the uninitialised tail of the bounce buffer to the backing store, and stops
the status phase from draining ep_out once the OUT data stage is over.

Patch 3 clears the scatter list when the BOT status request is reused, so
an sg-capable UDC no longer walks the freed scatterlist of the previous
command.

v7:
- New 3/3: clear req->num_sgs/req->sg in bot_send_bad_status() to fix a
use-after-free of the previous command's scatter list.
v6: 2/2 skips the ep_out drain whenever the OUT data stage has completed,
not only on a short packet.
v5: split the GFP_ATOMIC fix out as its own patch.
v4: keep cmd->data_len so the CSW residue stays correct; skip the drain
with a command flag.
v3: https://lore.kernel.org/linux-usb/20261013015416.2503787-1-yhlee@xxxxxxxxxxxxxxxxxx/
v2: https://lore.kernel.org/linux-usb/20261013005854.2470384-1-yhlee@xxxxxxxxxxxxxxxxxx/
v1: https://lore.kernel.org/linux-usb/20261012154422.2436134-1-yhlee@xxxxxxxxxxxxxxxxxx/

Yehyeong Lee (3):
usb: gadget: f_tcm: queue the BOT status requests with GFP_ATOMIC
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 | 21 ++++++++++++++++-----
drivers/usb/gadget/function/tcm.h | 1 +
2 files changed, 17 insertions(+), 5 deletions(-)


base-commit: 2c3418fffa9d037b2038a6db48be63f9e2291806
--
2.43.0