[PATCH] USB: cdc-acm: check for descriptors with invalid length

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In my scenario(pull that device then plug into another usb port while
booting), invalid descriptor accessing happens just like Simon reported.
Checking length and ignoring the invalid descriptors works.

References: https://bugzilla.kernel.org/show_bug.cgi?id=83551
Reported-by: Simon Schubert <2+kernel@xxxxxxxx>
Cc: stable <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Adam Lee <adam8157@xxxxxxxxx>
---
 drivers/usb/class/cdc-acm.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 546a17e8..347c14a 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1155,6 +1155,12 @@ static int acm_probe(struct usb_interface *intf,
 			ac_management_function = buffer[3];
 			break;
 		case USB_CDC_CALL_MANAGEMENT_TYPE:
+			if (buffer[0] < 5) {
+				dev_err(&intf->dev, "Ignoring descriptor with "
+					"invalid length: type %02x, length %d "
+					"instead of 5\n", buffer[2], buffer[0]);
+				goto next_desc;
+			}
 			call_management_function = buffer[3];
 			call_interface_num = buffer[4];
 			break;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux