From: Sung Byeongchan <tjdqudcks0424@naver.com>
To: valentina.manea.m@gmail.com, shuah@kernel.org
Cc: linux-usb@vger.kernel.org, Sung Byeongchan <tjdqudcks0424@naver.com>
Subject: [PATCH] usbip: clear actual length after receive failure
Date: Fri, 9 Oct 2026 21:26:36 +0900 [thread overview]
Message-ID: <20261009122636.642575-1-tjdqudcks0424@naver.com> (raw)
A USB/IP peer supplies actual_length in RET_SUBMIT. usbip_recv_xbuff()
rejects a value larger than the URB transfer buffer, but the VHCI error
path gives the URB back with the peer-controlled length still present.
usbfs subsequently uses urb->actual_length as its copy-to-userspace
extent, reading beyond the transfer-buffer allocation.
On current mainline target 0c2669a9f4a1d, a 65-byte completion for a
64-byte URB produced a KASAN slab-out-of-bounds read in _copy_to_user in
three fresh boots. INT_MAX reproduced the same first invalid consumer
three times. The one-byte case modified only a boolean sentinel oracle;
the copied value was not collected or characterized.
Clear actual_length when receiving the transfer buffer fails. No payload
is valid on this error path, and zero prevents downstream consumers from
reusing the rejected extent. The existing protocol-error path closes the
broken transport.
The fixed kernel rejected both triggers without KASAN in three fresh
boots each. Normal zero through buffer-length completions, OUT and ISO
controls, high-bit counterexamples, disconnect cleanup, and a following
valid transfer on a fresh transport remained functional.
This issue was found through manual source inspection assisted by an
AI/LLM, then evaluated with local production-path dynamic validation.
Fixes: aabb5b833872 ("usbip: Fix error path of vhci_recv_ret_submit()")
Assisted-by: LLM
Signed-off-by: Sung Byeongchan <tjdqudcks0424@naver.com>
---
drivers/usb/usbip/vhci_rx.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
index a678e7c898375..741107a964660 100644
--- a/drivers/usb/usbip/vhci_rx.c
+++ b/drivers/usb/usbip/vhci_rx.c
@@ -79,6 +79,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
/* recv transfer buffer */
if (usbip_recv_xbuff(ud, urb) < 0) {
urb->status = -EPROTO;
+ urb->actual_length = 0;
goto error;
}
--
2.43.0
next reply other threads:[~2026-10-09 12:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 12:26 Sung Byeongchan [this message]
2026-10-09 12:46 ` [PATCH] usbip: clear actual length after receive failure sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261009122636.642575-1-tjdqudcks0424@naver.com \
--to=tjdqudcks0424@naver.com \
--cc=linux-usb@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=valentina.manea.m@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox