From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.71.186 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796496953; b=XmVuEZoJSJ4jqO+Vio3Abh8si590BRwyqDf8V0R89IeXDad/9sfr1Z+h38yRQLOEUuNV wU8PNZIK7BIoVuBLRH3YNOTtqB5qaglbHaEjsV/IyEebZqdXHsiRELsGpY9U2hHPQxKBL HNoZf+40rk4vTYA927L4eKqk6v5vov2hMUmoz+rli6PP+H6GmB5+IK+9I4KcNLCyNqMcg bAJq5cXUH9HbpOclW4TJU3Slnhjs9T3MOtVfZGy06vVUl4HO3LF1PnVU0KXnb3phizkEe PYmPvOO11MCsc0/rrSXJaueDsPTQGDLu3ddxh4Ib6nlVTDI2k05E5HUEAmUAdaPXiNw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796496953; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-Report-Abuse:Feedback-ID:X-smtpcorp-track; bh=5PnvwIyZVd0tBUxLjS8hVplg8C1lbvb0KlHBCrx/Gjo=; b=VItxuIv9Zk2SJQtBc8O0T5zbAfZrhFx3qN6T2os5Ip6qC2mu325oGCCpQ7pC/bTdsg2D 6KeC1/7Y9sV39a0v4wfgORunmcB8AV+tPkf+01Chr44KwkB4D8/9UspLPgJ/4DM1RfqYA QE/FlrCtQfw4/v/N7pxBKHseH9kBL5NEcoAmV0FRmUloGVmXEMXEH1Pa1rlkhUBQaODzB 76SqpkRBFzgEzqxSpn3E/vrKnYZQ6Y5LfdjchNpeqpCzo0yLyOix2++dySSMCS3ApRs7X hClGRhnSQKBtjypBsVsRAYyAe4F2JLSY00rM+jcGTSsp8wUjSfwhQzk2OrehEwK4HNg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=marulee.dev; spf=pass smtp.mailfrom=em1321796.marulee.dev; dkim=pass header.d=marulee.dev header.i=@marulee.dev header.a=rsa-sha256 header.s=s1321796 header.b=P2PPyxY0; arc=none smtp.remote-ip=170.10.71.186 Received: from a5i186.smtp2go.com (a5i186.smtp2go.com [170.10.71.186]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1179606A32F for ; Sat, 5 Dec 2026 18:55:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D1179606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=marulee.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=em1321796.marulee.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=marulee.dev header.i=@marulee.dev header.a=rsa-sha256 header.s=s1321796 header.b=P2PPyxY0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marulee.dev; i=@marulee.dev; q=dns/txt; s=s1321796; t=1796496947; h=from : subject : to : message-id : date : list-unsubscribe : list-unsubscribe-post; bh=5PnvwIyZVd0tBUxLjS8hVplg8C1lbvb0KlHBCrx/Gjo=; b=P2PPyxY014TOiVM3Sh5KzOqNNsboTYwvgE+D/Y19uSXEoZN2skcDTKzSlqYe7ZCwuFjEt 1p7jJKAzkNKED8htD/3EpGe2oBFBjz9ZEP5ceQOLBrmN9nPacY+NvwWVuTZ5dlAx1JFXd2X t6cv0Zii7xPFTvrmWZXVlAQiLDbJZt5NZz5bjb0NItvMv7GOacoaQA0TR8uAa7n0+i6yfaL 73inffKwC/tIr1k1QQCH6YENJPFnyMP75DWhpi1TOKMiI9cIzh4Zrydgzm3tD07W+yIJhSp +g7LhoMhKbSiZ3+cH+wCM90GZ4XwSzQQmujihOcj/ZWX1DMa5krSvlMscAHA== Received: from [10.158.251.100] (helo=localhost.localdomain) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256:X25519) (Exim 4.100.1) (envelope-from ) id 1xZuv5-FnQW0hPm14T-nNQq; Sat, 05 Dec 2026 18:55:40 +0000 From: Yongjin Lee To: valentina.manea.m@gmail.com, shuah@kernel.org Cc: i@zenithal.me, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, Yongjin Lee , stable@vger.kernel.org Subject: [PATCH] usbip: stub: ignore peer NO_TRANSFER_DMA_MAP Date: Sun, 6 Dec 2026 03:55:16 +0900 Message-ID: <20261205185516.587-1-contact@marulee.dev> X-Mailer: git-send-email 2.47.1.windows.1 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Report-Abuse: Please forward a copy of this message, including all headers, to Feedback-ID: 1321796m:1321796ahC1hyf:1321796sLpYeYAySj X-smtpcorp-track: 3_ciVGn8qZ5f.IlDpk3YagIw_.twKQGANvjgn 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 --- 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