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