Skip to contentSkip to conversation

usb: serial: sierra: deal with insufficiently long notifications

PATCH In review Oliver Neukum 2 participants 2 messages Jul 15

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: serial: sierra: deal with insufficiently long notifications

A malicious device can send too short messages which would cause the driver to read beyond the part of the buffer holding valid data.
Ignore too short packets.

Fixes 033a3fb980b04 ("USB: Sierra Wireless driver update")

---

v2:
- fixed description and added reporters and fixes tag

 drivers/usb/serial/sierra.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/usb/serial/sierra.c +11 -1
index 6e443aacae07..f50833055360 100644
@@ -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)
Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 8 lines · Oliver Neukum

A malicious device can send too short messages which would cause the driver to read beyond the part of the buffer holding valid data.
Ignore too short packets.

Fixes 033a3fb980b04 ("USB: Sierra Wireless driver update")

You should add a Link to the report(s) as well. I only saw the one from Jay.

Quoted 35 lines

---

v2:
- fixed description and added reporters and fixes tag

 drivers/usb/serial/sierra.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/usb/serial/sierra.c +10 -1
index 6e443aacae07..f50833055360 100644
@@ -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));
 

drivers/usb/serial/sierra.c static void sierra_instat_callback(struct urb *urb) · line 615

Quoted 4 lines
drivers/usb/serial/sierra.c +1 -0
@@ -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:

Please move and rename this one as I suggested in my reply to v1.

drivers/usb/serial/sierra.c static void sierra_instat_callback(struct urb *urb) · line 618

Quoted 3 lines
drivers/usb/serial/sierra.c +0 -0
 		usb_mark_last_busy(serial->dev);
 		err = usb_submit_urb(urb, GFP_ATOMIC);
 		if (err && err != -EPERM)

Johan