All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] USB: iowarrior: fix missing endpoint sanity checks
@ 2017-03-07 15:11 Johan Hovold
  2017-03-07 15:11 ` [PATCH 1/2] USB: iowarrior: fix NULL-deref at probe Johan Hovold
  2017-03-07 15:11 ` [PATCH 2/2] USB: iowarrior: fix NULL-deref in write Johan Hovold
  0 siblings, 2 replies; 3+ messages in thread
From: Johan Hovold @ 2017-03-07 15:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Josh Boyer, stable, Johan Hovold

These patches add the missing endpoint sanity checks to probe that are
needed to prevent a couple of NULL-derefs which could be trigger by a
malicious device.

Johan


Johan Hovold (2):
  USB: iowarrior: fix NULL-deref at probe
  USB: iowarrior: fix NULL-deref in write

 drivers/usb/misc/iowarrior.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

-- 
2.12.0

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

* [PATCH 1/2] USB: iowarrior: fix NULL-deref at probe
  2017-03-07 15:11 [PATCH 0/2] USB: iowarrior: fix missing endpoint sanity checks Johan Hovold
@ 2017-03-07 15:11 ` Johan Hovold
  2017-03-07 15:11 ` [PATCH 2/2] USB: iowarrior: fix NULL-deref in write Johan Hovold
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2017-03-07 15:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Josh Boyer, stable, Johan Hovold

Make sure to check for the required interrupt-in endpoint to avoid
dereferencing a NULL-pointer should a malicious device lack such an
endpoint.

Note that a fairly recent change purported to fix this issue, but added
an insufficient test on the number of endpoints only, a test which can
now be removed.

Fixes: 4ec0ef3a8212 ("USB: iowarrior: fix oops with malicious USB
descriptors")
Fixes: 946b960d13c1 ("USB: add driver for iowarrior devices.")
Cc: stable <stable@vger.kernel.org>	# 2.6.21
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/misc/iowarrior.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 095778ff984d..3ad058cbe6ca 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -781,12 +781,6 @@ static int iowarrior_probe(struct usb_interface *interface,
 	iface_desc = interface->cur_altsetting;
 	dev->product_id = le16_to_cpu(udev->descriptor.idProduct);
 
-	if (iface_desc->desc.bNumEndpoints < 1) {
-		dev_err(&interface->dev, "Invalid number of endpoints\n");
-		retval = -EINVAL;
-		goto error;
-	}
-
 	/* set up the endpoint information */
 	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
 		endpoint = &iface_desc->endpoint[i].desc;
@@ -797,6 +791,13 @@ static int iowarrior_probe(struct usb_interface *interface,
 			/* this one will match for the IOWarrior56 only */
 			dev->int_out_endpoint = endpoint;
 	}
+
+	if (!dev->int_in_endpoint) {
+		dev_err(&interface->dev, "no interrupt-in endpoint found\n");
+		retval = -ENODEV;
+		goto error;
+	}
+
 	/* we have to check the report_size often, so remember it in the endianness suitable for our machine */
 	dev->report_size = usb_endpoint_maxp(dev->int_in_endpoint);
 	if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) &&
-- 
2.12.0

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

* [PATCH 2/2] USB: iowarrior: fix NULL-deref in write
  2017-03-07 15:11 [PATCH 0/2] USB: iowarrior: fix missing endpoint sanity checks Johan Hovold
  2017-03-07 15:11 ` [PATCH 1/2] USB: iowarrior: fix NULL-deref at probe Johan Hovold
@ 2017-03-07 15:11 ` Johan Hovold
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2017-03-07 15:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Josh Boyer, stable, Johan Hovold

Make sure to verify that we have the required interrupt-out endpoint for
IOWarrior56 devices to avoid dereferencing a NULL-pointer in write
should a malicious device lack such an endpoint.

Fixes: 946b960d13c1 ("USB: add driver for iowarrior devices.")
Cc: stable <stable@vger.kernel.org>     # 2.6.21
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/misc/iowarrior.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 3ad058cbe6ca..37c63cb39714 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -798,6 +798,14 @@ static int iowarrior_probe(struct usb_interface *interface,
 		goto error;
 	}
 
+	if (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56) {
+		if (!dev->int_out_endpoint) {
+			dev_err(&interface->dev, "no interrupt-out endpoint found\n");
+			retval = -ENODEV;
+			goto error;
+		}
+	}
+
 	/* we have to check the report_size often, so remember it in the endianness suitable for our machine */
 	dev->report_size = usb_endpoint_maxp(dev->int_in_endpoint);
 	if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) &&
-- 
2.12.0

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

end of thread, other threads:[~2017-03-08  2:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-07 15:11 [PATCH 0/2] USB: iowarrior: fix missing endpoint sanity checks Johan Hovold
2017-03-07 15:11 ` [PATCH 1/2] USB: iowarrior: fix NULL-deref at probe Johan Hovold
2017-03-07 15:11 ` [PATCH 2/2] USB: iowarrior: fix NULL-deref in write Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.