Linux USB
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Sung Byeongchan <tjdqudcks0424@naver.com>,
	valentina.manea.m@gmail.com, shuah@kernel.org
Cc: linux-usb@vger.kernel.org, Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] usbip: clear actual length after receive failure
Date: Mon, 19 Oct 2026 13:30:24 -0600	[thread overview]
Message-ID: <98ab6ab5-ab3f-4b15-a841-e3059526d054@linuxfoundation.org> (raw)
In-Reply-To: <20261009122636.642575-1-tjdqudcks0424@naver.com>

On 10/9/26 06:26, Sung Byeongchan wrote:
> 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;

What happens without this code change? The code path follows the
error leg because of EPROTO? So how does setting actual_length to
zero help?

thanks,
-- Shuah

      parent reply	other threads:[~2026-10-19 19:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 12:26 [PATCH] usbip: clear actual length after receive failure Sung Byeongchan
2026-10-09 12:46 ` sashiko-bot
2026-10-19 19:30 ` Shuah Khan [this message]

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=98ab6ab5-ab3f-4b15-a841-e3059526d054@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=tjdqudcks0424@naver.com \
    --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