Linux USB
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Tristan Madani <tristmd@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Kevin Lloyd <linux@sierrawireless.com>,
	linux-usb@vger.kernel.org, stable@vger.kernel.org,
	Tristan Madani <tristan@talencesecurity.com>
Subject: Re: [PATCH] USB: serial: sierra: validate URB length in instat callback
Date: Mon, 19 Oct 2026 08:41:12 +0200	[thread overview]
Message-ID: <atW7iCuqfmpJ5pp8@hovoldconsulting.com> (raw)
In-Reply-To: <20261018223352.2021650-1-tristmd@gmail.com>

On Sun, Oct 18, 2026 at 10:33:52PM +0000, Tristan Madani wrote:
> From: Tristan Madani <tristan@talencesecurity.com>
> 
> sierra_instat_callback() reads one byte past the usb_ctrlrequest
> header at offset sizeof(struct usb_ctrlrequest) without first
> checking that urb->actual_length is large enough to contain it.
> A short USB interrupt transfer could cause an out-of-bounds read.
> 
> Add a length check matching the pattern already present in the
> option driver (option_instat_callback), which validates the same
> field access.
> 
> Fixes: 033a3fb980b041 ("USB: Sierra Wireless driver update")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
> ---
>  drivers/usb/serial/sierra.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
> index 6e443aacae07d..8f800cde25229 100644
> --- a/drivers/usb/serial/sierra.c
> +++ b/drivers/usb/serial/sierra.c
> @@ -575,6 +575,11 @@ static void sierra_instat_callback(struct urb *urb)
>  				__func__);
>  			return;
>  		}
> +		if (urb->actual_length < sizeof(*req_pkt) + 1) {
> +			dev_dbg(&port->dev, "%s: short interrupt transfer\n",
> +				__func__);
> +			return;
> +		}

This silently breaks a theoretical device that submits requests without
payload not yet handled by the driver (the else branch below).

Please split this up in two checks; one for the header and one for the
line state data as in the option driver.

And since you prevent any further interrupts if you ever hit this, you
should use dev_err().


>  		if ((req_pkt->bRequestType == 0xA1) &&
>  				(req_pkt->bRequest == 0x20)) {
>  			int old_dcd_state;

Johan

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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-18 22:33 [PATCH] USB: serial: sierra: validate URB length in instat callback Tristan Madani
2026-10-18 22:40 ` sashiko-bot
2026-10-19  6:41 ` Johan Hovold [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=atW7iCuqfmpJ5pp8@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@sierrawireless.com \
    --cc=stable@vger.kernel.org \
    --cc=tristan@talencesecurity.com \
    --cc=tristmd@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