Skip to content

Commit af4e234

Browse files
jhovoldgregkh
authored andcommitted
USB: hub: fix SS hub-descriptor handling
commit 2c25a2c818023df64463aac3288a9f969491e507 upstream. A SuperSpeed hub descriptor does not have any variable-length fields so bail out when reading a short descriptor. This avoids parsing and leaking two bytes of uninitialised slab data through sysfs removable-attributes. Fixes: dbe79bb ("USB 3.0 Hub Changes") Cc: John Youn <John.Youn@synopsys.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1e6e9c4 commit af4e234

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/usb/core/hub.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,12 @@ static int get_hub_descriptor(struct usb_device *hdev, void *data)
376376
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB,
377377
dtype << 8, 0, data, size,
378378
USB_CTRL_GET_TIMEOUT);
379-
if (ret >= (USB_DT_HUB_NONVAR_SIZE + 2))
379+
if (hub_is_superspeed(hdev)) {
380+
if (ret == size)
381+
return ret;
382+
} else if (ret >= (USB_DT_HUB_NONVAR_SIZE + 2)) {
380383
return ret;
384+
}
381385
}
382386
return -EINVAL;
383387
}
@@ -1303,7 +1307,7 @@ static int hub_configure(struct usb_hub *hub,
13031307

13041308
/* Request the entire hub descriptor.
13051309
* hub->descriptor can handle USB_MAXCHILDREN ports,
1306-
* but the hub can/will return fewer bytes here.
1310+
* but a (non-SS) hub can/will return fewer bytes here.
13071311
*/
13081312
ret = get_hub_descriptor(hdev, hub->descriptor);
13091313
if (ret < 0) {

0 commit comments

Comments
 (0)