Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: hub: add check for unsupported bus topology

We can't allow hubs on the 7th tier as they would allow
devices on the 8th tier.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Felipe Balbi and committed by
Greg Kroah-Hartman
38f3ad5e 6deb270b

+8 -2
-2
drivers/usb/core/devices.c
··· 61 61 #include "usb.h" 62 62 #include "hcd.h" 63 63 64 - #define MAX_TOPO_LEVEL 6 65 - 66 64 /* Define ALLOW_SERIAL_NUMBER if you want to see the serial number of devices */ 67 65 #define ALLOW_SERIAL_NUMBER 68 66
+2
drivers/usb/core/hcd.h
··· 21 21 22 22 #include <linux/rwsem.h> 23 23 24 + #define MAX_TOPO_LEVEL 6 25 + 24 26 /* This file contains declarations of usbcore internals that are mostly 25 27 * used or exposed by Host Controller Drivers. 26 28 */
+6
drivers/usb/core/hub.c
··· 1051 1051 desc = intf->cur_altsetting; 1052 1052 hdev = interface_to_usbdev(intf); 1053 1053 1054 + if (hdev->level == MAX_TOPO_LEVEL) { 1055 + dev_err(&intf->dev, "Unsupported bus topology: " 1056 + "hub nested too deep\n"); 1057 + return -E2BIG; 1058 + } 1059 + 1054 1060 #ifdef CONFIG_USB_OTG_BLACKLIST_HUB 1055 1061 if (hdev->parent) { 1056 1062 dev_warn(&intf->dev, "ignoring external hub\n");