d752a74
From 3620ebad64a327113bed34edefd45c3605086fc6 Mon Sep 17 00:00:00 2001
d752a74
From: Josh Boyer <jwboyer@fedoraproject.org>
d752a74
Date: Mon, 14 Mar 2016 10:38:31 -0400
d752a74
Subject: [PATCH] USB: iowarrior: fix oops with malicious USB descriptors
d752a74
d752a74
The iowarrior driver expects at least one valid endpoint.  If given
d752a74
malicious descriptors that specify 0 for the number of endpoints,
d752a74
it will crash in the probe function.  Ensure there is at least
d752a74
one endpoint on the interface before using it.
d752a74
d752a74
The full report of this issue can be found here:
d752a74
http://seclists.org/bugtraq/2016/Mar/87
d752a74
d752a74
Reported-by: Ralf Spenneberg <ralf@spenneberg.net>
d752a74
Cc: stable <stable@vger.kernel.org>
d752a74
Signed-off-by: Josh Boyer <jwboyer@fedoraproject.org>
d752a74
---
d752a74
 drivers/usb/misc/iowarrior.c | 6 ++++++
d752a74
 1 file changed, 6 insertions(+)
d752a74
d752a74
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
d752a74
index c6bfd13f6c92..1950e87b4219 100644
d752a74
--- a/drivers/usb/misc/iowarrior.c
d752a74
+++ b/drivers/usb/misc/iowarrior.c
d752a74
@@ -787,6 +787,12 @@ static int iowarrior_probe(struct usb_interface *interface,
d752a74
 	iface_desc = interface->cur_altsetting;
d752a74
 	dev->product_id = le16_to_cpu(udev->descriptor.idProduct);
d752a74
 
d752a74
+	if (iface_desc->desc.bNumEndpoints < 1) {
d752a74
+		dev_err(&interface->dev, "Invalid number of endpoints\n");
d752a74
+		retval = -EINVAL;
d752a74
+		goto error;
d752a74
+	}
d752a74
+
d752a74
 	/* set up the endpoint information */
d752a74
 	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
d752a74
 		endpoint = &iface_desc->endpoint[i].desc;
d752a74
-- 
d752a74
2.5.0
d752a74