Commit e50a322e authored by Josef Gajdusek's avatar Josef Gajdusek Committed by Greg Kroah-Hartman

usb: Do not re-read descriptors for wired devices in usb_authorize_device()

This patch modifies the usb_authorize_device() function such as that it does
not reload the device descriptor for wired devices. The reasons for this
are as follows:

* Some devices dislike the master requesting the descriptor from them twice,
  failing on the usb_get_device_descriptor() call with -ETIMEOUT. Observed this
  on my Pretec 16GB flash drive (4146:ba65).

* Malicious device could send two different descriptors - one before
  authorization, used by userspace to determine whether to authorize it and
  second to be actually used by the kernel when determining which drivers to
  bind.
Signed-off-by: default avatarJosef Gajdusek <atx@atx.name>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dd3cf174
...@@ -2543,12 +2543,15 @@ int usb_authorize_device(struct usb_device *usb_dev) ...@@ -2543,12 +2543,15 @@ int usb_authorize_device(struct usb_device *usb_dev)
"can't autoresume for authorization: %d\n", result); "can't autoresume for authorization: %d\n", result);
goto error_autoresume; goto error_autoresume;
} }
if (usb_dev->wusb) {
result = usb_get_device_descriptor(usb_dev, sizeof(usb_dev->descriptor)); result = usb_get_device_descriptor(usb_dev, sizeof(usb_dev->descriptor));
if (result < 0) { if (result < 0) {
dev_err(&usb_dev->dev, "can't re-read device descriptor for " dev_err(&usb_dev->dev, "can't re-read device descriptor for "
"authorization: %d\n", result); "authorization: %d\n", result);
goto error_device_descriptor; goto error_device_descriptor;
} }
}
usb_dev->authorized = 1; usb_dev->authorized = 1;
/* Choose and set the configuration. This registers the interfaces /* Choose and set the configuration. This registers the interfaces
......
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