Skip to content

Commit bfa8ffb

Browse files
szymonhgregkh
authored andcommitted
USB: gadget: validate endpoint index for xilinx udc
commit 7f14c72 upstream. Assure that host may not manipulate the index to point past endpoint array. Signed-off-by: Szymon Heidrich <szymon.heidrich@gmail.com> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4ce247a commit bfa8ffb

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎drivers/usb/gadget/udc/udc-xilinx.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,8 @@ static void xudc_getstatus(struct xusb_udc *udc)
16121612
break;
16131613
case USB_RECIP_ENDPOINT:
16141614
epnum = udc->setup.wIndex & USB_ENDPOINT_NUMBER_MASK;
1615+
if (epnum >= XUSB_MAX_ENDPOINTS)
1616+
goto stall;
16151617
target_ep = &udc->ep[epnum];
16161618
epcfgreg = udc->read_fn(udc->addr + target_ep->offset);
16171619
halt = epcfgreg & XUSB_EP_CFG_STALL_MASK;
@@ -1679,6 +1681,10 @@ static void xudc_set_clear_feature(struct xusb_udc *udc)
16791681
case USB_RECIP_ENDPOINT:
16801682
if (!udc->setup.wValue) {
16811683
endpoint = udc->setup.wIndex & USB_ENDPOINT_NUMBER_MASK;
1684+
if (endpoint >= XUSB_MAX_ENDPOINTS) {
1685+
xudc_ep0_stall(udc);
1686+
return;
1687+
}
16821688
target_ep = &udc->ep[endpoint];
16831689
outinbit = udc->setup.wIndex & USB_ENDPOINT_DIR_MASK;
16841690
outinbit = outinbit >> 7;

0 commit comments

Comments
 (0)