Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: serial: sierra: deal with insufficiently long notifications
@ 2026-07-14 18:33 Oliver Neukum
  2026-07-15  7:22 ` Johan Hovold
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Neukum @ 2026-07-14 18:33 UTC (permalink / raw)
  To: gregkh, johan, jkrshnmenon, linux-usb; +Cc: Oliver Neukum

A malicious device can send too short messages which
would cause the driver to overflow the buffer and hit
stale data in their interpretation.
Ignore too short packets.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
 drivers/usb/serial/sierra.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 6e443aacae07..f50833055360 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -575,10 +575,19 @@ static void sierra_instat_callback(struct urb *urb)
 				__func__);
 			return;
 		}
+
+		if (urb->actual_length < sizeof(struct usb_ctrlrequest))
+			goto skip_too_short;
+
 		if ((req_pkt->bRequestType == 0xA1) &&
 				(req_pkt->bRequest == 0x20)) {
 			int old_dcd_state;
-			unsigned char signals = *((unsigned char *)
+			unsigned char signals;
+
+			if (urb->actual_length < sizeof(struct usb_ctrlrequest) + 1)
+				goto skip_too_short;
+
+			signals = *((unsigned char *)
 					urb->transfer_buffer +
 					sizeof(struct usb_ctrlrequest));
 
@@ -603,6 +612,7 @@ static void sierra_instat_callback(struct urb *urb)
 
 	/* Resubmit urb so we continue receiving IRQ data */
 	if (status != -ESHUTDOWN && status != -ENOENT) {
+skip_too_short:
 		usb_mark_last_busy(serial->dev);
 		err = usb_submit_urb(urb, GFP_ATOMIC);
 		if (err && err != -EPERM)
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-15 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-14 18:33 [PATCH] usb: serial: sierra: deal with insufficiently long notifications Oliver Neukum
2026-07-15  7:22 ` Johan Hovold
2026-07-15 10:05   ` Oliver Neukum
2026-07-15 12:18     ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox