]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
usb: gadget: aspeed_udc: validate endpoint index for ast udc
authorMa Ke <make24@iscas.ac.cn>
Tue, 25 Jun 2024 02:23:06 +0000 (10:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jun 2024 14:07:30 +0000 (16:07 +0200)
We should verify the bound of the array to assure that host
may not manipulate the index to point past endpoint array.

Found by static analysis.

Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Acked-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Link: https://lore.kernel.org/r/20240625022306.2568122-1-make24@iscas.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/aspeed_udc.c

index 3916c8e2ba01f18c6afbcbda4ab20898699fd6dc..d972ef4644bc6012753d793b425260eba3839bf2 100644 (file)
@@ -1009,6 +1009,8 @@ static void ast_udc_getstatus(struct ast_udc_dev *udc)
                break;
        case USB_RECIP_ENDPOINT:
                epnum = crq.wIndex & USB_ENDPOINT_NUMBER_MASK;
+               if (epnum >= AST_UDC_NUM_ENDPOINTS)
+                       goto stall;
                status = udc->ep[epnum].stopped;
                break;
        default: