* [PATCH] usbip: stub: ignore peer NO_TRANSFER_DMA_MAP
@ 2026-12-05 18:55 Yongjin Lee
2026-12-05 19:13 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Yongjin Lee @ 2026-12-05 18:55 UTC (permalink / raw)
To: valentina.manea.m, shuah; +Cc: i, gregkh, linux-usb, Yongjin Lee, stable
The stub driver allocates transfer buffers and relies on the USB core to
map them for DMA. A peer can set USBIP_URB_NO_TRANSFER_DMA_MAP, which the
stub translates to URB_NO_TRANSFER_DMA_MAP. This skips the mapping,
leaving the HCD to use urb->transfer_dma even though the stub never sets
it and the peer cannot supply a valid server-side DMA address.
Clear the wire flag before constructing URBs, and remove the URB flag
from the allowed mask. The early clear also covers paths that return
before masking_bogus_flags() applies its mask.
On a no-IOMMU QEMU xHCI guest, a peer-supplied flag caused the host
controller to write device data outside the allocated transfer buffer.
With this change, the same request returned the expected data, as did
the normal control request. The same EP0 comparison passed on Linux
6.18.66 and on mainline revision
28a23309c8e40d651faf4cc3cc9b71458a11b987.
OpenAI Codex (GPT-6) assisted in tracing the flag and drafting the fix
and changelog. The result was checked with source review and the QEMU
before/after test described above.
Fixes: 4d7b5c7f8ad4 ("Staging: USB/IP: add host driver")
Cc: stable@vger.kernel.org
Signed-off-by: Yongjin Lee <contact@marulee.dev>
---
Notes (usbip-submission):
Full x86_64 KASAN builds passed, with no new W=1 warnings.
drivers/usb/usbip/stub_rx.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c
index 1e9ae578810..04164022047 100644
--- a/drivers/usb/usbip/stub_rx.c
+++ b/drivers/usb/usbip/stub_rx.c
@@ -429,8 +429,7 @@ static void masking_bogus_flags(struct urb *urb)
}
/* enforce simple/standard policy */
- allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT |
- URB_DIR_MASK | URB_FREE_BUFFER);
+ allowed = URB_NO_INTERRUPT | URB_DIR_MASK | URB_FREE_BUFFER;
switch (xfertype) {
case USB_ENDPOINT_XFER_BULK:
if (is_out)
@@ -482,6 +481,10 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
if (pipe == -1)
return;
+ /* The remote peer has no server-side DMA address for this buffer. */
+ pdu->u.cmd_submit.transfer_flags &=
+ ~USBIP_URB_NO_TRANSFER_DMA_MAP;
+
/*
* Smatch reported the error case where use_sg is true and buf_len is 0.
* In this case, It adds SDEV_EVENT_ERROR_MALLOC and stub_priv will be
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] usbip: stub: ignore peer NO_TRANSFER_DMA_MAP
2026-12-05 18:55 [PATCH] usbip: stub: ignore peer NO_TRANSFER_DMA_MAP Yongjin Lee
@ 2026-12-05 19:13 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-05 19:13 UTC (permalink / raw)
To: Yongjin Lee; +Cc: linux-usb
> The stub driver allocates transfer buffers and relies on the USB core to
> map them for DMA. A peer can set USBIP_URB_NO_TRANSFER_DMA_MAP, which the
> stub translates to URB_NO_TRANSFER_DMA_MAP. This skips the mapping,
> leaving the HCD to use urb->transfer_dma even though the stub never sets
> it and the peer cannot supply a valid server-side DMA address.
>
> Clear the wire flag before constructing URBs, and remove the URB flag
> from the allowed mask. The early clear also covers paths that return
> before masking_bogus_flags() applies its mask.
>
> On a no-IOMMU QEMU xHCI guest, a peer-supplied flag caused the host
> controller to write device data outside the allocated transfer buffer.
> With this change, the same request returned the expected data, as did
> the normal control request. The same EP0 comparison passed on Linux
> 6.18.66 and on mainline revision
> 28a23309c8e40d651faf4cc3cc9b71458a11b987.
>
> OpenAI Codex (GPT-6) assisted in tracing the flag and drafting the fix
> and changelog. The result was checked with source review and the QEMU
> before/after test described above.
>
> Fixes: 4d7b5c7f8ad4 ("Staging: USB/IP: add host driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yongjin Lee <contact@marulee.dev>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205185516.587-1-contact@marulee.dev?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-05 19:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 18:55 [PATCH] usbip: stub: ignore peer NO_TRANSFER_DMA_MAP Yongjin Lee
2026-12-05 19:13 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.