Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sung Byeongchan" <tjdqudcks0424@naver.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usbip: clear actual length after receive failure
Date: Fri, 09 Oct 2026 12:46:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-165560@kernel.org> (raw)
In-Reply-To: <20261009122636.642575-1-tjdqudcks0424@naver.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usbip: incomplete fix for OOB read due to signedness bug in usbip_recv_xbuff
--

commit ba9987eb570270d32daa1e8937dfdcfa997cbe46
Author: Sung Byeongchan <tjdqudcks0424@naver.com>

usbip: clear actual length after receive failure

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.

> 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;

[Severity: High]
Does this completely prevent the out-of-bounds read if a malicious USB/IP
server provides a high-bit length like 0x80000000?

Looking at usbip_recv_xbuff() in drivers/usb/usbip/usbip_common.c,
urb->actual_length (which is a u32) is assigned to a signed int:

	int size;
	...
	} else {
		/* the direction of urb must be IN. */
		if (usb_pipeout(urb->pipe))
			return 0;

		size = urb->actual_length;
	}

	/* no need to recv xbuff */
	if (!(size > 0))
		return 0;

Because size is a signed int, a high-bit value becomes negative, making the
(!(size > 0)) check evaluate to true. This causes usbip_recv_xbuff() to
return 0 (success) early, completely bypassing the bounds check against
urb->transfer_buffer_length.

Since usbip_recv_xbuff() falsely reports success for these high-bit values,
it appears this new mitigation will be skipped entirely. This would allow
the URB to complete with the massive actual_length intact, still triggering
the KASAN out-of-bounds read in usbfs.

>  		goto error;
>  	}
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261009122636.642575-1-tjdqudcks0424@naver.com?part=1

      reply	other threads:[~2026-10-09 12:46 UTC|newest]

Thread overview: 2+ 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 [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=sashiko-outbox-165560@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tjdqudcks0424@naver.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