* [PATCH] usb: gadget: dummy_hcd: Reject hub port requests for non-existent ports
@ 2026-05-18 23:43 pip-izony
2026-05-19 2:17 ` Alan Stern
0 siblings, 1 reply; 2+ messages in thread
From: pip-izony @ 2026-05-18 23:43 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Seungjin Bae, Alan Stern, Kees Cook, Chen Ni, Sebastian Urban,
Ingo Molnar, linux-usb, linux-kernel
From: Seungjin Bae <eeodqql09@gmail.com>
The `dummy_hub_control()` function handles USB hub class requests
to the virtual root hub. The `GetPortStatus` case returns -EPIPE for
requests with `wIndex != 1`, since the virtual root hub has only a
single port. However, the `ClearPortFeature` and `SetPortFeature`
cases lack the same check.
Fix this by extending the `wIndex != 1` rejection to both cases,
matching the existing behavior of `GetPortStatus`.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Seungjin Bae <eeodqql09@gmail.com>
---
drivers/usb/gadget/udc/dummy_hcd.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index f094491b1041..f47903461ed5 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -2134,6 +2134,8 @@ static int dummy_hub_control(
case ClearHubFeature:
break;
case ClearPortFeature:
+ if (wIndex != 1)
+ goto error;
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
if (hcd->speed == HCD_USB3) {
@@ -2248,6 +2250,8 @@ static int dummy_hub_control(
retval = -EPIPE;
break;
case SetPortFeature:
+ if (wIndex != 1)
+ goto error;
switch (wValue) {
case USB_PORT_FEAT_LINK_STATE:
if (hcd->speed != HCD_USB3) {
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] usb: gadget: dummy_hcd: Reject hub port requests for non-existent ports
2026-05-18 23:43 [PATCH] usb: gadget: dummy_hcd: Reject hub port requests for non-existent ports pip-izony
@ 2026-05-19 2:17 ` Alan Stern
0 siblings, 0 replies; 2+ messages in thread
From: Alan Stern @ 2026-05-19 2:17 UTC (permalink / raw)
To: pip-izony
Cc: Greg Kroah-Hartman, Kees Cook, Chen Ni, Sebastian Urban,
Ingo Molnar, linux-usb, linux-kernel
On Mon, May 18, 2026 at 07:43:14PM -0400, pip-izony wrote:
> From: Seungjin Bae <eeodqql09@gmail.com>
>
> The `dummy_hub_control()` function handles USB hub class requests
> to the virtual root hub. The `GetPortStatus` case returns -EPIPE for
> requests with `wIndex != 1`, since the virtual root hub has only a
> single port. However, the `ClearPortFeature` and `SetPortFeature`
> cases lack the same check.
>
> Fix this by extending the `wIndex != 1` rejection to both cases,
> matching the existing behavior of `GetPortStatus`.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Suggested-by: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: Seungjin Bae <eeodqql09@gmail.com>
> ---
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
> drivers/usb/gadget/udc/dummy_hcd.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
> index f094491b1041..f47903461ed5 100644
> --- a/drivers/usb/gadget/udc/dummy_hcd.c
> +++ b/drivers/usb/gadget/udc/dummy_hcd.c
> @@ -2134,6 +2134,8 @@ static int dummy_hub_control(
> case ClearHubFeature:
> break;
> case ClearPortFeature:
> + if (wIndex != 1)
> + goto error;
> switch (wValue) {
> case USB_PORT_FEAT_SUSPEND:
> if (hcd->speed == HCD_USB3) {
> @@ -2248,6 +2250,8 @@ static int dummy_hub_control(
> retval = -EPIPE;
> break;
> case SetPortFeature:
> + if (wIndex != 1)
> + goto error;
> switch (wValue) {
> case USB_PORT_FEAT_LINK_STATE:
> if (hcd->speed != HCD_USB3) {
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-19 2:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-18 23:43 [PATCH] usb: gadget: dummy_hcd: Reject hub port requests for non-existent ports pip-izony
2026-05-19 2:17 ` Alan Stern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®