From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Fan Wu <12321260@zju.edu.cn>
Cc: Fan Wu <fanwu01@zju.edu.cn>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] usb: typec: ucsi: acpi: Fix use-after-free of ucsi on remove
Date: Wed, 22 Jul 2026 18:51:54 +0300 [thread overview]
Message-ID: <amDnGh33sH-yo8nb@kuha> (raw)
In-Reply-To: <F4203724-2CD7-446A-B766-79015B8E37B2@zju.edu.cn>
Hi Fan,
On Tue, Jul 21, 2026 at 10:47:59PM +0800, Fan Wu wrote:
>
>
> > On Jul 21, 2026, at 16:27, Heikki Krogerus <heikki.krogerus@linux.intel.com> wrote:
> >
> >
> > I don't think this is enough. You now create a window where the ucsi
> > is unregistered, but you can still call ucsi_notify_common(),
> > ucsi_connector_change(), etc. So you'll end up with even more problems.
> >
> > If I understood correctly the long explanation (I'm guessing generated
> > by gpt-5.6), the problem is that ucsi_unregister() disables the
> > notification, but it does not flush them. My proposal is that you fix
> > that by setting the ua->ucsi to NULL after calling ucsi_unregister()
> > and then always check it in ucsi_acpi_notify(). You probable also need
> > a lock for that.
> >
> > thanks,
> >
> > --
> > heikki
>
> Thank you, you are right. The proposed reordering does not protect the
> connector state freed by ucsi_unregister(), while the notify handler can
> still enter ucsi_notify_common() and ucsi_connector_change().
>
> I also see that simply serializing the handler with ucsi_unregister()
> could prevent pending command completions needed by work being cancelled
> there. Thus, a driver-local reorder or NULL check alone is not sufficient.
>
> I will drop this patch and investigate the appropriate synchronization
> scheme. Do you have a preferred direction: should this be handled by a
> core-UCSI quiesce interface, or by a transport-side locking protocol?
Let's keep this in ucsi_acpi.c for now.
Thanks,
--
heikki
prev parent reply other threads:[~2026-07-22 15:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-18 2:11 [PATCH] usb: typec: ucsi: acpi: Fix use-after-free of ucsi on remove Fan Wu
2026-07-21 8:27 ` Heikki Krogerus
2026-07-21 14:47 ` Fan Wu
2026-07-22 15:51 ` Heikki Krogerus [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=amDnGh33sH-yo8nb@kuha \
--to=heikki.krogerus@linux.intel.com \
--cc=12321260@zju.edu.cn \
--cc=fanwu01@zju.edu.cn \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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