Commit c4b51661 authored by Johan Hovold's avatar Johan Hovold Committed by Sasha Levin

USB: iowarrior: fix NULL-deref at probe

[ Upstream commit b7321e81 ]

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: 4ec0ef3a ("USB: iowarrior: fix oops with malicious USB descriptors")
Fixes: 946b960d ("USB: add driver for iowarrior devices.")
Cc: stable <stable@vger.kernel.org>	# 2.6.21
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
parent 4db7a852
...@@ -787,12 +787,6 @@ static int iowarrior_probe(struct usb_interface *interface, ...@@ -787,12 +787,6 @@ static int iowarrior_probe(struct usb_interface *interface,
iface_desc = interface->cur_altsetting; iface_desc = interface->cur_altsetting;
dev->product_id = le16_to_cpu(udev->descriptor.idProduct); 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 */ /* set up the endpoint information */
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
endpoint = &iface_desc->endpoint[i].desc; endpoint = &iface_desc->endpoint[i].desc;
...@@ -803,6 +797,13 @@ static int iowarrior_probe(struct usb_interface *interface, ...@@ -803,6 +797,13 @@ static int iowarrior_probe(struct usb_interface *interface,
/* this one will match for the IOWarrior56 only */ /* this one will match for the IOWarrior56 only */
dev->int_out_endpoint = endpoint; 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 */ /* 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); dev->report_size = usb_endpoint_maxp(dev->int_in_endpoint);
if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) && if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment