mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jay Vadayath <jkrshnmenon@gmail.com>
To: gregkh@linuxfoundation.org, johan@kernel.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jay Vadayath <jkrshnmenon@gmail.com>,
	stable@vger.kernel.org, Lukas Dresel <lukas@artiphishell.com>
Subject: [PATCH] USB: serial: sierra: fix slab out-of-bounds read in sierra_instat_callback
Date: Tue, 14 Jul 2026 11:11:42 -0700	[thread overview]
Message-ID: <20260714181142.10976-1-jkrshnmenon@gmail.com> (raw)
In-Reply-To: <https://lore.kernel.org/all/2026071453-reminder-ageless-dcea@gregkh/>

The interrupt-in URB buffer is allocated based on the endpoint's
wMaxPacketSize. A device declaring wMaxPacketSize == 8 gets an 8-byte
buffer from kmalloc-8. When such a device delivers a short packet,
sierra_instat_callback() still dereferences transfer_buffer as struct
usb_ctrlrequest and reads a further byte at data[sizeof(*req_pkt)], one
byte past the end of the allocation.

Reject the URB when fewer than sizeof(struct usb_ctrlrequest) + 1 bytes
were received.

Cc: stable@vger.kernel.org
Reported-by: Jay Vadayath <jkrshnmenon@gmail.com>
Reported-by: Lukas Dresel <lukas@artiphishell.com>
Signed-off-by: Jay Vadayath <jkrshnmenon@gmail.com>
---
Apologies for the wall of text in the original mail. I wanted to include
the artifacts inline so the bug could be independently verified. Just the
patch this time.

Same shape of fix as Jiale Yao's option.c patch:
https://lore.kernel.org/all/20260712170012.3503601-1-yaojiale02@163.com/

Tested with the reproducer against v7.2-rc3. The KASAN splat does not
appear with the patch applied.

 drivers/usb/serial/sierra.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 6e443aacae07..4c6e7120695e 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -575,6 +575,13 @@ static void sierra_instat_callback(struct urb *urb)
 				__func__);
 			return;
 		}
+
+		if (urb->actual_length < sizeof(struct usb_ctrlrequest) + 1) {
+			dev_dbg(&port->dev, "%s: short interrupt transfer: %d bytes\n",
+				__func__, urb->actual_length);
+			return;
+		}
+
 		if ((req_pkt->bRequestType == 0xA1) &&
 				(req_pkt->bRequest == 0x20)) {
 			int old_dcd_state;
--
2.51.2

       reply	other threads:[~2026-07-14 18:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <https://lore.kernel.org/all/2026071453-reminder-ageless-dcea@gregkh/>
2026-07-14 18:11 ` Jay Vadayath [this message]
2026-07-14 18:25   ` Oliver Neukum
2026-07-15  7:21   ` Johan Hovold

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=20260714181142.10976-1-jkrshnmenon@gmail.com \
    --to=jkrshnmenon@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lukas@artiphishell.com \
    --cc=stable@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®