From: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
To: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
Cc: "stable@vger.kernel.org" <stable@vger.kernel.org>,
"hdegoede@redhat.com" <hdegoede@redhat.com>,
"heikki.krogerus@linux.intel.com"
<heikki.krogerus@linux.intel.com>
Subject: Re: [PATCH] usb: ucsi: Fix ucsi->connector race
Date: Mon, 3 Apr 2023 15:25:46 +0200 [thread overview]
Message-ID: <2023040323-secluding-unicycle-cf5e@gregkh> (raw)
In-Reply-To: <9e01760d96a5e235631f9e6d73a4dcb21aaeaf41.camel@infinera.com>
On Thu, Mar 30, 2023 at 04:28:56PM +0000, Joakim Tjernlund wrote:
> On Wed, 2023-03-29 at 10:03 +0200, Joakim Tjernlund wrote:
> > From: Hans de Goede <hdegoede@redhat.com>
> >
> > ucsi_init() which runs from a workqueue sets ucsi->connector and
> > on an error will clear it again.
> >
> > ucsi->connector gets dereferenced by ucsi_resume(), this checks for
> > ucsi->connector being NULL in case ucsi_init() has not finished yet;
> > or in case ucsi_init() has failed.
> >
> > ucsi_init() setting ucsi->connector and then clearing it again on
> > an error creates a race where the check in ucsi_resume() may pass,
> > only to have ucsi->connector free-ed underneath it when ucsi_init()
> > hits an error.
> >
> > Fix this race by making ucsi_init() store the connector array in
> > a local variable and only assign it to ucsi->connector on success.
> >
> > Fixes: bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")
> > Cc: stable@vger.kernel.org
> > Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> > Link: https://lore.kernel.org/r/20230308154244.722337-3-hdegoede@redhat.com
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > (cherry picked from commit 0482c34ec6f8557e06cd0f8e2d0e20e8ede6a22c)
> > Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> > ---
> >
> > - This is a dry port to 6.1.x, will be some time before it will be tested.
>
> Tested OK now on 6.1.22
Thanks, now queued up for 6.2.y and 6.1.y. Still need backports for
older kernels if you want to do that...
thanks,
greg k-h
prev parent reply other threads:[~2023-04-03 13:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 12:01 FAILED: patch "[PATCH] usb: ucsi: Fix ucsi->connector race" failed to apply to 6.2-stable tree gregkh
2023-03-29 8:03 ` [PATCH] usb: ucsi: Fix ucsi->connector race Joakim Tjernlund
2023-03-30 16:28 ` Joakim Tjernlund
2023-04-03 13:25 ` gregkh [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=2023040323-secluding-unicycle-cf5e@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=Joakim.Tjernlund@infinera.com \
--cc=hdegoede@redhat.com \
--cc=heikki.krogerus@linux.intel.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.