Linux driver-core infrastructure
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: PETER Mario <mario.peter@leica-geosystems.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	"driver-core@lists.linux.dev" <driver-core@lists.linux.dev>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] driver core: take parent lock in async device attach
Date: Wed, 14 Oct 2026 15:38:02 +0200	[thread overview]
Message-ID: <as-FumLy7e1BedqS@hovoldconsulting.com> (raw)
In-Reply-To: <c465c6a3-d189-4304-a7ea-feb3eea33674@leica-geosystems.com>

On Tue, Oct 13, 2026 at 03:41:28PM +0000, PETER Mario wrote:
> On 10/13/26 16:04, Johan Hovold wrote:

> > @@ -1038,7 +1070,7 @@ static void __device_attach_async_helper(void *_dev, async_cookie_t cookie)
> >                 .want_async     = true,
> >         };
> > 
> > -       device_lock(dev);
> > +       __device_driver_lock(dev, dev->parent);
> 
> Thanks for picking this up and for fixing the deadlock.
> 
> The use-after-free that the AI review flags here is real, I can
> trigger it in QEMU. With a debug delay before this line,
> driver_async_probe=usb,hub, and dummy_hcd unbound while the probe of
> the emulated hub's usb_device waited, KASAN reports a
> slab-use-after-free in __mutex_lock() called from
> __device_attach_async_helper(), on the root hub. An interface pins its
> usb_device, but a usb_device doesn't pin its parent hub, and dev drops
> its reference to the parent in device_del(). v2 has the same problem.

Thanks for checking. I can also trigger a UAF through some existing
paths when disconnecting a hub (with some instrumentation to increase
the race window).

I've just sent a v2 series for the deferred probe fix that also
addresses the UAF issue and includes your fix:

	https://lore.kernel.org/all/20261014133109.1392265-1-johan@kernel.org/

Johan

      reply	other threads:[~2026-10-14 13:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 14:04 [PATCH v3] driver core: take parent lock in async device attach Johan Hovold
2026-10-13 15:41 ` PETER Mario
2026-10-14 13:38   ` Johan Hovold [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=as-FumLy7e1BedqS@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=dakr@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mario.peter@leica-geosystems.com \
    --cc=rafael@kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox