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: avoid dereferencing a missing device in receive errors
Date: Thu, 08 Oct 2026 13:51:32 +0000	[thread overview]
Message-ID: <sashiko-outbox-164251@kernel.org> (raw)
In-Reply-To: <20261008134107.265827-1-tjdqudcks0424@naver.com>

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

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

usbip: avoid dereferencing a missing device in receive errors

This commit adds NULL checks for urb->dev across several shared receive and
ISO diagnostic paths in USB/IP. This prevents kernel crashes when a missing
device dereference occurs, such as when processing synthetic URBs built by
VUDC.

> diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
> index 100f8920624bb..8d379a9437efa 100644
> --- a/drivers/usb/usbip/usbip_common.c
> +++ b/drivers/usb/usbip/usbip_common.c

[ ... ]

> @@ -891,7 +897,9 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb)
>  	return ret;
>  
>  error:
> -	dev_err(&urb->dev->dev, "recv xbuf, %d\n", ret);
> +	/* VUDC creates synthetic URBs without a struct usb_device. */
> +	if (urb->dev)
> +		dev_err(&urb->dev->dev, "recv xbuf, %d\n", ret);

[Severity: High]
Does the signedness of the size variable earlier in usbip_recv_xbuff() allow
an out-of-bounds read?

When handling the actual length, urb->actual_length (which is a u32) is
implicitly converted to a signed int:

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

	if (size > urb->transfer_buffer_length)
		/* should not happen, probably malicious packet */
		goto error;

If a malicious USB/IP server sends a USBIP_RET_SUBMIT packet with an
actual_length greater than 0x7FFFFFFF, size will become negative.

The check !(size > 0) will then evaluate to true, causing the function to
immediately return 0 and bypass the bounds check against
urb->transfer_buffer_length that normally jumps to this error path.

Could this allow the client driver to process the buffer using the forged
actual_length, resulting in an out-of-bounds read beyond its allocated
transfer_buffer?

>  	if (ud->side == USBIP_STUB || ud->side == USBIP_VUDC)
>  		usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
>  	else

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

      reply	other threads:[~2026-10-08 13:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08 13:41 [PATCH] usbip: avoid dereferencing a missing device in receive errors Sung Byeongchan
2026-10-08 13:51 ` 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-164251@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