Skip to content

Commit f880aac

Browse files
committed
usb: gadget: renesas_usb3: validate endpoint index in standard request handlers
The GET_STATUS and SET/CLEAR_FEATURE handlers extract the endpoint number from the host-supplied wIndex without any sort of validation. Fix this up by validating the number of endpoints actually match up with the number the device has before attempting to dereference a pointer based on this math. This is just like what was done in commit ee0d382 ("usb: gadget: aspeed_udc: validate endpoint index for ast udc") for the aspeed driver. Fixes: 746bfe6 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller") Cc: stable <stable@kernel.org> Assisted-by: gregkh_clanker_t1000 Link: https://patch.msgid.link/2026040647-sincerity-untidy-b104@gregkh Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 274875f commit f880aac

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/usb/gadget/udc/renesas_usb3.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,10 @@ static bool usb3_std_req_get_status(struct renesas_usb3 *usb3,
16691669
break;
16701670
case USB_RECIP_ENDPOINT:
16711671
num = le16_to_cpu(ctrl->wIndex) & USB_ENDPOINT_NUMBER_MASK;
1672+
if (num >= usb3->num_usb3_eps) {
1673+
stall = true;
1674+
break;
1675+
}
16721676
usb3_ep = usb3_get_ep(usb3, num);
16731677
if (usb3_ep->halt)
16741678
status |= 1 << USB_ENDPOINT_HALT;
@@ -1781,7 +1785,8 @@ static bool usb3_std_req_feature_endpoint(struct renesas_usb3 *usb3,
17811785
struct renesas_usb3_ep *usb3_ep;
17821786
struct renesas_usb3_request *usb3_req;
17831787

1784-
if (le16_to_cpu(ctrl->wValue) != USB_ENDPOINT_HALT)
1788+
if ((le16_to_cpu(ctrl->wValue) != USB_ENDPOINT_HALT) ||
1789+
(num >= usb3->num_usb3_eps))
17851790
return true; /* stall */
17861791

17871792
usb3_ep = usb3_get_ep(usb3, num);

0 commit comments

Comments
 (0)