From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org,
Yehezkel Bernat <YehezkelShB@gmail.com>,
Michael Jamet <michael.jamet@intel.com>,
Lukas Wunner <lukas@wunner.de>,
Andreas Noever <andreas.noever@gmail.com>,
Kenneth Crudup <kenny@panix.com>
Subject: Re: [PATCH] thunderbolt: Prevent use-after-free in resume from hibernate
Date: Thu, 6 Mar 2025 18:00:46 +0200 [thread overview]
Message-ID: <20250306160046.GW3713119@black.fi.intel.com> (raw)
In-Reply-To: <2025030644-unbraided-drool-647f@gregkh>
On Thu, Mar 06, 2025 at 04:45:22PM +0100, Greg KH wrote:
> On Thu, Mar 06, 2025 at 10:41:45AM +0200, Mika Westerberg wrote:
> > Kenneth noticed that his laptop crashes randomly when resuming from
> > hibernate if there is device connected and display tunneled. I was able
> > to reproduce this as well with the following steps:
> >
> > 1. Boot the system up, nothing connected.
> > 2. Connect Thunderbolt 4 dock to the host.
> > 3. Connect monitor to the Thunderbolt 4 dock.
> > 4. Verify that there is picture on the screen.
> > 5. Enter hibernate.
> > 6. Exit hibernate.
> > 7. Wait for the system to resume.
> >
> > Expectation: System resumes just fine, the connected monitor still
> > shows screen.
> > Actual result: There is crash during resume, screen is blank.
> >
> > What happens is that during resume from hibernate we tear down any
> > existing tunnels created by the boot kernel and this ends up calling
> > tb_dp_dprx_stop() which calls tb_tunnel_put() dropping the reference
> > count to zero even though we never called tb_dp_dprx_start() for it (we
> > never do that for discovery). This makes the discovered DP tunnel memory
> > to be released and any access after that causes use-after-free and
> > possible crash.
> >
> > Fix this so that we only stop DPRX flow if it has been started in the
> > first place.
> >
> > Reported-by: Kenneth Crudup <kenny@panix.com>
> > Closes: https://lore.kernel.org/linux-usb/8e175721-806f-45d6-892a-bd3356af80c9@panix.com/
> > Cc: stable@vger.kernel.org
> > Fixes: d6d458d42e1e ("thunderbolt: Handle DisplayPort tunnel activation asynchronously")
> > Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> > ---
> > drivers/thunderbolt/tunnel.c | 11 ++++++++---
> > drivers/thunderbolt/tunnel.h | 2 ++
> > 2 files changed, 10 insertions(+), 3 deletions(-)
>
> Want me to take this now? Or are you going to send it on in a later
> pull request to me? Whichever is easier for you is fine with me.
I will send it later in a pull request, thanks!
prev parent reply other threads:[~2025-03-06 16:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 8:41 [PATCH] thunderbolt: Prevent use-after-free in resume from hibernate Mika Westerberg
2025-03-06 10:29 ` Yehezkel Bernat
2025-03-07 12:02 ` Mika Westerberg
2025-03-06 15:45 ` Greg KH
2025-03-06 16:00 ` Mika Westerberg [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=20250306160046.GW3713119@black.fi.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kenny@panix.com \
--cc=linux-usb@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=michael.jamet@intel.com \
/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