Re: [PATCH] usb: gadget: aspeed: clamp transfer length in RX completion handlers
From: Greg KH
Date: Fri Nov 20 2026 - 08:59:58 EST
On Thu, Sep 17, 2026 at 06:32:04PM +0800, Liu Chao wrote:
> ast_udc_ep0_out(), ast_udc_epn_handle() and ast_udc_epn_handle_desc()
> read the received byte count from hardware registers and add it to
> req->req.actual without clamping against the remaining buffer space
> (req->req.length - req->req.actual).
>
> When actual reaches or exceeds length, the subsequent DMA has already
> written past the end of the request buffer. Across multiple short
> packets the overrun grows with each completion.
>
> A malicious or malfunctioning USB host can exploit this to trigger a
> heap buffer overflow in any gadget function (e.g. f_mass_storage,
> f_fs) layered on top of this UDC.
We trust the hardware here, so how can this happen?