]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
usb: host: max3421: Fix shift-out-of-bounds in max3421_hub_control()
authorSeungjin Bae <eeodqql09@gmail.com>
Mon, 18 May 2026 22:49:00 +0000 (18:49 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 22 May 2026 09:35:18 +0000 (11:35 +0200)
The `max3421_hub_control()` function handles USB hub class requests
to the virtual root hub. In the `default` branches of both the
`ClearPortFeature` and `SetPortFeature` switch statements, it modifies
`max3421_hcd->port_status` by left shifting 1 by the request's `value`
parameter. However, it does not validate whether this shift will exceed
the width of `port_status`.

So if a malicious userspace task with access to the root hub via
/dev/bus/usb/.../001 issues a USBDEVFS_CONTROL ioctl with `wValue`
greater than or equal to 32, the left shift operation invokes
shift-out-of-bounds undefined behavior. This results in arbitrary
bit corruption of `port_status`, including the normally-immutable
change bits, which can bypass internal state checks and confuse the
hub status.

Fix this by rejecting requests whose `value` exceeds the shift width
before performing the shift.

This issue was found using a KLEE-based symbolic execution tool for
kernel drivers that I'm currently developing.

Fixes: 2d53139f3162 ("Add support for using a MAX3421E chip as a host driver.")
Signed-off-by: Seungjin Bae <eeodqql09@gmail.com>
Link: https://patch.msgid.link/20260518224901.1887013-1-eeodqql09@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/max3421-hcd.c

index 0e17c988d36a2dd2458f34018da82d0f16cf58cc..3d6b351dcb1a2814188bd301b21683b461c69289 100644 (file)
@@ -1694,6 +1694,8 @@ max3421_hub_control(struct usb_hcd *hcd, u16 type_req, u16 value, u16 index,
                                                !pdata->vbus_active_level);
                        fallthrough;
                default:
+                       if (value >= 32)
+                               goto error;
                        max3421_hcd->port_status &= ~(1 << value);
                }
                break;
@@ -1747,6 +1749,8 @@ max3421_hub_control(struct usb_hcd *hcd, u16 type_req, u16 value, u16 index,
                        max3421_reset_port(hcd);
                        fallthrough;
                default:
+                       if (value >= 32)
+                               goto error;
                        if ((max3421_hcd->port_status & USB_PORT_STAT_POWER)
                            != 0)
                                max3421_hcd->port_status |= (1 << value);