u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix out of bound access of ep array.
@ 2022-09-22  4:01 Alison Huffman
  2022-09-25 23:50 ` Marek Vasut
  0 siblings, 1 reply; 2+ messages in thread
From: Alison Huffman @ 2022-09-22  4:01 UTC (permalink / raw)
  To: u-boot; +Cc: Alison Huffman, Lukasz Majewski, Marek Vasut

When processing USB_REQ_CLEAR_FEATURE, USB_REQ_SET_FEATURE, and
USB_REQ_GET_STATUS packets in dwc2_ep0_setup an out of bounds access
can occur. This is caused by the wIndex field of the usb control packet
being used as an index into an array whose size is DWC2_MAX_ENDPOINTS (4).

Signed-off-by: Alison Huffman <alisn@google.com>
---

 drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
index f17009a29e..1c34b75351 100644
--- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
+++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
@@ -890,7 +890,7 @@ static int dwc2_ep0_write(struct dwc2_udc *dev)
 static int dwc2_udc_get_status(struct dwc2_udc *dev,
 		struct usb_ctrlrequest *crq)
 {
-	u8 ep_num = crq->wIndex & 0x7F;
+	u8 ep_num = crq->wIndex & 0x3;
 	u16 g_status = 0;
 	u32 ep_ctrl;
 
@@ -1418,7 +1418,7 @@ static void dwc2_ep0_setup(struct dwc2_udc *dev)
 			break;
 
 		case USB_REQ_CLEAR_FEATURE:
-			ep_num = usb_ctrl->wIndex & 0x7f;
+			ep_num = usb_ctrl->wIndex & 0x3;
 
 			if (!dwc2_udc_clear_feature(&dev->ep[ep_num].ep))
 				return;
@@ -1426,7 +1426,7 @@ static void dwc2_ep0_setup(struct dwc2_udc *dev)
 			break;
 
 		case USB_REQ_SET_FEATURE:
-			ep_num = usb_ctrl->wIndex & 0x7f;
+			ep_num = usb_ctrl->wIndex & 0x3;
 
 			if (!dwc2_udc_set_feature(&dev->ep[ep_num].ep))
 				return;
-- 
2.37.3.968.ga6b4b080e4-goog


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

* Re: [PATCH] Fix out of bound access of ep array.
  2022-09-22  4:01 [PATCH] Fix out of bound access of ep array Alison Huffman
@ 2022-09-25 23:50 ` Marek Vasut
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Vasut @ 2022-09-25 23:50 UTC (permalink / raw)
  To: Alison Huffman, u-boot; +Cc: Lukasz Majewski

On 9/22/22 06:01, Alison Huffman wrote:
> When processing USB_REQ_CLEAR_FEATURE, USB_REQ_SET_FEATURE, and
> USB_REQ_GET_STATUS packets in dwc2_ep0_setup an out of bounds access
> can occur. This is caused by the wIndex field of the usb control packet
> being used as an index into an array whose size is DWC2_MAX_ENDPOINTS (4).

Applied to usb/master, thanks !

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

end of thread, other threads:[~2022-09-25 23:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22  4:01 [PATCH] Fix out of bound access of ep array Alison Huffman
2022-09-25 23:50 ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).