lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251104113248.223594-4-lec.jakub@gmail.com>
Date: Tue,  4 Nov 2025 12:32:48 +0100
From: Jakub Lecki <lec.jakub@...il.com>
To: linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: Valentina Manea <valentina.manea.m@...il.com>,
	Shuah Khan <shuah@...nel.org>,
	Hongren Zheng <i@...ithal.me>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Jakub Lecki <lec.jakub@...il.com>
Subject: [PATCH 3/3] usbip: Limit maximum number of virtual host controllers to 31.

When loading the vhci-hcd module with number of virtual host controllers
configured to max value of 128, the module initialization fails due to
insufficient number of available IDs for USB busses.

Each virtual host controller registers two usb hubs (USB2.0 & USB3.0) to
the usb core, each with a unique bus number. The number of USB busses is
limited by ID allocation range [1 .. USB_MAXBUS - 1] (defined in
usb_register_bus()). Therefore, VHCI_MAX_NR_HCS must not be greater than
(USB_MAXBUS - 1) / 2 = 31.

In real world scenarios the maximum number of virtual host controllers
possible to create may be even lower as other USB host controllers may
be registered. In this case, the module initialization failure is
correct as the number of virtual host controllers must be adjusted by
a user to a given use-case.

Signed-off-by: Jakub Lecki <lec.jakub@...il.com>
---
 drivers/usb/usbip/vhci.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/usbip/vhci.h b/drivers/usb/usbip/vhci.h
index 2772d923a8cb..3b0ea4038e51 100644
--- a/drivers/usb/usbip/vhci.h
+++ b/drivers/usb/usbip/vhci.h
@@ -76,8 +76,17 @@ enum hub_speed {
 #define VHCI_DEFAULT_HC_PORTS 8
 #define VHCI_MAX_HC_PORTS USB_SS_MAXPORTS
 
+/*
+ * Number of supported virtual host controllers. Value has upperbound of
+ * maximum possible usb busses.
+ * It is limited by a bus ID allocation in [1 .. USB_MAXBUS - 1] range,
+ * resulting in maximum of USB_MAXBUS - 1 usb busses allocated.
+ * Additionally, each virtual host controller registers 2 usb hubs (USB2.0
+ * & USB3.0), therefore maximum number of virtual host controllers is:
+ * (USB_MAXBUS - 1) / 2
+ */
 #define VHCI_DEFAULT_NR_HCS 1
-#define VHCI_MAX_NR_HCS 128
+#define VHCI_MAX_NR_HCS 31
 
 #define MAX_STATUS_NAME 16
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ