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=1796496952; b=m5PYXM3jn/yB28V26Fl6fKU53vCcjOeewsPw//yyZ7vK3GY+kiGyLogElNlKxaslS8Cl a9obAE7lVh4K1/E3qXX15gbwjN1JT312BTZrQJ1LvlFH8hKDs4bROAfzfjI/iru0oAyg7 7LNBBX4Tw8qbA15Ip6Wr/gGie0tv0mussa1jViBBcdWN25S/sb06BV734VdB14h/b1ywX agkk/mhm+CNL8OyfJllqAhoOUP/OIVz6RO0urABmo9sUuHAtsuF2dL+swkesqVXnUiU94 i/WEEvi8rNQrUeqoLj5FMXXmwjX9kdCAbF2huLEjbFkiVR8Qk5zGJZlYRlHATs7wEeQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796496952; 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=cvzIcRHv4rHKUBrNoVY0d/tJsWDJZ1dxnbMuYqJt36FylIN2+GHTpE9epFAJln5nl0HW 5Hayi80FTq/fve1/mKE2+8oXIY6jqkowwr1quNQ5EDVv+laMdbekwK8dBRTiZXyxIbbb/ VvBA1Gw96bNObkCfK7XjViuYprXf8st6+15/BJ4yWn+dReE4L+WQC4ldLCqG69vvoVh1k DvLDKx8xE5Il7EEV6FOjCfQOX9ReOjgAkbOZ0LwrNe1RnEzYZK5PdqDjWZIYVrIlVO0mZ W/Sa5b4e0kLayCQqkqr6hAIR+AhouACAvg5SnocO+LY3D6Gvml9myp81Uh6rgpHFT/g== 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=cvMmDk66; 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 01E65606A31F for ; Sat, 5 Dec 2026 18:55:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 01E65606A31F 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=cvMmDk66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marulee.dev; i=@marulee.dev; q=dns/txt; s=s1321796; t=1796496945; h=from : subject : to : message-id : date : list-unsubscribe : list-unsubscribe-post; bh=5PnvwIyZVd0tBUxLjS8hVplg8C1lbvb0KlHBCrx/Gjo=; b=cvMmDk66lb1dGLLpFk4SAcbtrtDLuPEwn7BmVBuhM1nxdUhtAhhhPhGF9Zxyz1/UH5VVs KgYLmWMlMLQIdSrR8Y4tV2dp3FmUduhEDxz+Fgha7g3bNfAHqL8Bk2W6aXZPj6NZ+YVqzRu yJYIiM4ozC1bHNOSE5rWyh+Np2vQQK2ok7zhSM5vAe3Fzv497fT8BFW5fxSyUuNJNPaupPa TGac46BV+RMKiRB3OyoP4Yl9spfv48qa/BGXRD6YWQUqz/2/3kvY1BA+5fRf9UsX9WJMiDV 6ijFTU5aq1MW0gnt10KFvhCBCB6d2iyLq8HPP8hclzuyCDHMZW09Rek7UVpg== 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: linux-usb@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: czE3T-4_yhvE.L-i4oZVgCm_h.Yi0cTA12Tu4 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