[PATCH v6 0/2] usb: gadget: f_tcm: fix a short write infoleak and a completion-path sleep

From: Yehyeong Lee

Date: Tue Oct 13 2026 - 02:27:15 EST


Two fixes in the f_tcm BOT completion path, both reachable from a remote
USB host.

Patch 1 is a sleep-in-atomic that came up reviewing v4:
bot_send_bad_status() and bot_send_status() queue requests with GFP_KERNEL
from endpoint completion callbacks, which run with interrupts disabled. It
predates the infoleak fix, so it goes first.

Patch 2 is the short write data-out infoleak this series started as: a BOT
host that sends less than it declared leaves the command buffer tail
uninitialised and f_tcm commits the full declared length to the backing
store. It also stops the status phase from draining ep_out once the OUT
data stage is over, which otherwise wedges the bulk pipe on a failed write.

v6:
- 2/2: skip the ep_out drain whenever the OUT data stage has completed, not
only on a short packet, so a full write the backend rejects no longer
wedges the pipe.
v5: split the GFP_ATOMIC fix out as patch 1/2.
v4: keep cmd->data_len so the CSW residue stays correct; skip the drain
with a command flag (v2/v3 cleared data_len, zeroing the residue).
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 (2):
usb: gadget: f_tcm: queue the BOT status requests with GFP_ATOMIC
usb: gadget: f_tcm: reject a short write data-out transfer

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


base-commit: 2c3418fffa9d037b2038a6db48be63f9e2291806
--
2.43.0