[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250629214943.27893-4-eeodqql09@gmail.com>
Date: Sun, 29 Jun 2025 17:49:45 -0400
From: Seungjin Bae <eeodqql09@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: pip-izony <eeodqql09@...il.com>,
Kyungtae Kim <Kyungtae.Kim@...tmouth.edu>,
Jassi Brar <jaswinder.singh@...aro.org>,
Felipe Balbi <balbi@...nel.org>,
linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: [PATCH v2 1/2] usb: gadget: max3420_udc: Fix out-of-bounds endpoint index access
In the max3420_set_clear_feature() function, the endpoint index `id` can have a value from 0 to 15.
However, the udc->ep array is initialized with a maximum of 4 endpoints in max3420_eps_init().
If host sends a request with a wIndex greater than 3, the access to `udc->ep[id]` will go out-of-bounds,
leading to memory corruption or a potential kernel crash.
This bug was found by code inspection and has not been tested on hardware.
Fixes: 48ba02b2e2b1a ("usb: gadget: add udc driver for max3420")
Cc: stable@...r.kernel.org
Signed-off-by: Seungjin Bae <eeodqql09@...il.com>
---
v1 -> v2: Added a second patch to fix an out-of-bounds bug in the max3420_getstatus() function.
drivers/usb/gadget/udc/max3420_udc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/gadget/udc/max3420_udc.c b/drivers/usb/gadget/udc/max3420_udc.c
index 7349ea774adf..e4ecc7f7f3be 100644
--- a/drivers/usb/gadget/udc/max3420_udc.c
+++ b/drivers/usb/gadget/udc/max3420_udc.c
@@ -596,6 +596,8 @@ static void max3420_set_clear_feature(struct max3420_udc *udc)
break;
id = udc->setup.wIndex & USB_ENDPOINT_NUMBER_MASK;
+ if (id >= MAX3420_MAX_EPS)
+ break;
ep = &udc->ep[id];
spin_lock_irqsave(&ep->lock, flags);
--
2.43.0
Powered by blists - more mailing lists