Re: [PATCH] usb: gadget: udc-xilinx: clamp bytes_to_rx in xudc_ep0_out()
From: Greg KH
Date: Fri Nov 20 2026 - 09:12:52 EST
On Thu, Sep 17, 2026 at 08:31:11PM +0800, Liu Chao wrote:
> xudc_ep0_out() reads the received byte count from a hardware register
> and adds it to req->usb_req.actual without checking whether it exceeds
> the remaining buffer space (req->usb_req.length - req->usb_req.actual).
> The same unclamped count is then passed to memcpy_toio(), which can
> write past the end of the request buffer.
>
> A malicious USB host can send more data than the gadget function
> expects on a control OUT transfer, triggering a heap buffer overflow.
>
> Note that Haofeng Li's recent patch for the non-EP0 path
> (xudc_read_fifo) explicitly excludes EP0, so this code path was not
> covered by that fix.
>
> Clamp bytes_to_rx to the remaining buffer space before accumulating it.
>
> Fixes: 1f7b0c6d8e34 ("usb: gadget: udc-xilinx: Add Software data structures and APIs for xilinx udc")
Don't make up git ids. You did this for many of your patches, I've
dropped them all now.
greg k-h