All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: gadget: fix off-by-one in ep_from_windex bounds check
@ 2026-10-26  3:11 Fang Xieyan
  2026-10-26  3:48 ` sashiko-bot
  2026-10-26  7:26 ` Fang Xieyan
  0 siblings, 2 replies; 3+ messages in thread
From: Fang Xieyan @ 2026-10-26  3:11 UTC (permalink / raw)
  To: hminas, gregkh; +Cc: linux-usb, linux-kernel, stable, Guanglei Zhu

ep_from_windex() uses idx > hsotg->num_of_eps to validate the
endpoint index. Since valid indices are below num_of_eps, an index
equal to num_of_eps passes the check and is used to access
eps_in[] or eps_out[] out of bounds. This can cause an unintended
endpoint pointer to be used by subsequent request handling.

Reject indices greater than or equal to num_of_eps to prevent the
out-of-bounds access.

Fixes: b3f489b2b658 ("usb:hsotg:samsung: Determine number of EPs from HW configuration register")
Reviewed-by: Guanglei Zhu <zhugl3@xiaopeng.com>
Signed-off-by: Fang Xieyan <fangxy@xiaopeng.com>
---
 drivers/usb/dwc2/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 0637bfbc0..b2a25cd5c 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1582,7 +1582,7 @@ static struct dwc2_hsotg_ep *ep_from_windex(struct dwc2_hsotg *hsotg,
 	if (windex >= 0x100)
 		return NULL;
 
-	if (idx > hsotg->num_of_eps)
+	if (idx >= hsotg->num_of_eps)
 		return NULL;
 
 	return index_to_ep(hsotg, idx, dir);
--
2.50.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: dwc2: gadget: fix off-by-one in ep_from_windex bounds check
  2026-10-26  3:11 [PATCH] usb: dwc2: gadget: fix off-by-one in ep_from_windex bounds check Fang Xieyan
@ 2026-10-26  3:48 ` sashiko-bot
  2026-10-26  7:26 ` Fang Xieyan
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-10-26  3:48 UTC (permalink / raw)
  To: Fang Xieyan; +Cc: linux-usb

> ep_from_windex() uses idx > hsotg->num_of_eps to validate the
> endpoint index. Since valid indices are below num_of_eps, an index
> equal to num_of_eps passes the check and is used to access
> eps_in[] or eps_out[] out of bounds. This can cause an unintended
> endpoint pointer to be used by subsequent request handling.
> 
> Reject indices greater than or equal to num_of_eps to prevent the
> out-of-bounds access.
> 
> Fixes: b3f489b2b658 ("usb:hsotg:samsung: Determine number of EPs from HW configuration register")
> Reviewed-by: Guanglei Zhu <zhugl3@xiaopeng.com>
> Signed-off-by: Fang Xieyan <fangxy@xiaopeng.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261026031138.35911-1-fangxy@xiaopeng.com?part=1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: dwc2: gadget: fix off-by-one in ep_from_windex bounds check
  2026-10-26  3:11 [PATCH] usb: dwc2: gadget: fix off-by-one in ep_from_windex bounds check Fang Xieyan
  2026-10-26  3:48 ` sashiko-bot
@ 2026-10-26  7:26 ` Fang Xieyan
  1 sibling, 0 replies; 3+ messages in thread
From: Fang Xieyan @ 2026-10-26  7:26 UTC (permalink / raw)
  To: Thinh.Nguyen; +Cc: gregkh, linux-usb, linux-kernel, stable, zhugl3

Adding Thinh Nguyen to the discussion as the DWC2 maintainer.

The original email to Minas Harutyunyan's address was bounced.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-26  7:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-26  3:11 [PATCH] usb: dwc2: gadget: fix off-by-one in ep_from_windex bounds check Fang Xieyan
2026-10-26  3:48 ` sashiko-bot
2026-10-26  7:26 ` Fang Xieyan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.