[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Y+LJa8ZuBaD1DwlL@google.com>
Date: Tue, 7 Feb 2023 21:58:03 +0000
From: Xin Zhao <xnzhao@...gle.com>
To: John Keeping <john@...anate.com>
Cc: Alan Stern <stern@...land.harvard.edu>, gregkh@...uxfoundation.org,
jakobkoschel@...il.com, rdunlap@...radead.org, ira.weiny@...el.com,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] usb: gadget: dummyhcd: Fix use-after-free in
dummy_free_request
On Tue, Feb 07, 2023 at 11:59:25AM +0000, John Keeping wrote:
> On Mon, Feb 06, 2023 at 07:34:40PM -0500, Alan Stern wrote:
> > On Mon, Feb 06, 2023 at 10:52:58PM +0000, Xin Zhao wrote:
> > > DummyHCD assume when dummy_free_request is called, the request
> > > is already detached from request queues. It is correct in most
> > > cases.
> > > But when DummyHCD is detached from gadget configfs with pending
> > > requests and some requests are still in pending queue,
> > > dummy_free_request would free them directly.
> > > Later on, dummy_udc_stop would iterate pending queue to release
> > > the requests again.
> > >
> > > Stacktrace for dummy_free_reqeust
> > > ```
> > > kfree(const void * x) (slub.c:4200)
> > > dummy_free_request(struct usb_ep * _ep, struct usb_request * _req) (dummy_hcd.c:691)
> > > usb_ep_free_request(struct usb_ep * ep, struct usb_request * req) (core.c:201)
> > > functionfs_unbind(struct ffs_data * ffs) (f_fs.c:1894)
> >
> > That's the bug right there. The kerneldoc for usb_ep_free_request()
> > says "Caller guarantees the request is not queued". So it looks like
> > the real solution is to fix functionfs_unbind().
>
> This is commit ce405d561b02 ("usb: gadget: f_fs: Ensure ep0req is
> dequeued before free_request") IIUC.
>
> Xin, are you able to test a version with that commit?
Yes John, the commit may fix the issue. Thanks for bring it up.
Powered by blists - more mailing lists