From: sashiko-bot@kernel.org
To: "Mika Westerberg" <mika.westerberg@linux.intel.com>,
linux-usb@vger.kernel.org
Subject: Re: [PATCH 01/18] thunderbolt: Avoid leaking of DMA tunnel after XDomain removal
Date: Thu, 19 Nov 2026 17:32:00 +0000 [thread overview]
Message-ID: <sashiko-outbox-223699@kernel.org> (raw)
In-Reply-To: <20261119171232.1616316-2-mika.westerberg@linux.intel.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] thunderbolt: use-after-free of unplugged xdomain via
tb_xdomain_resume() [1]
--
commit 2656e124696e0ac2d72fefe13421cb4187bc49b6
Author: Mika Westerberg (Intel) <westeri@kernel.org>
thunderbolt: Avoid leaking of DMA tunnel after XDomain removal
This commit moves the xd->is_unplugged checks and adapter lookups under
tb->lock in tb_approve_xdomain_paths() and tb_disconnect_xdomain_paths()
to prevent creating or leaking DMA tunnels while an XDomain is being
unregistered.
> diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
> index 418ad0a61a5de..655bcc699410e 100644
> --- a/drivers/thunderbolt/tb.c
> +++ b/drivers/thunderbolt/tb.c
> @@ -2336,12 +2336,18 @@ static int tb_approve_xdomain_paths(struct tb *tb, struct tb_xdomain *xd,
> struct tb_switch *sw;
> int ret;
>
> + mutex_lock(&tb->lock);
> +
> + /* The XDomain is going away so no new tunnels allowed */
> + if (xd->is_unplugged) {
> + ret = -ENODEV;
> + goto err_unlock;
> + }
[Severity: High]
This problem wasn't introduced by this patch, but can tb_xdomain_resume()
trigger a use-after-free on an unplugged XDomain [1]?
Commit a8937f35cf39 ("thunderbolt: Remove XDomain from the bus without
holding tb->lock") deferred unregistering unplugged XDomains from
tb_resume_noirq() to tb_complete(). Because xd->dev remains registered
during the intervening dpm_resume phase, tb_xdomain_resume() runs without
checking xd->removing or xd->is_unplugged and restarts xd->state_work
after tb_xdomain_remove() has already stopped it:
CPU0 kworker
tb_resume_noirq()
...
tb_xdomain_remove(xd)
xd->removing = true
stop_handshake(xd)
tb_xdomain_resume(&xd->dev)
start_handshake(xd)
queue_delayed_work(..., &xd->state_work, ...)
tb_complete()
...
tb_xdomain_unregister(xd)
device_unregister(&xd->dev)
tb_xdomain_release(&xd->dev)
kfree(xd)
tb_xdomain_state_work()
xd->... <-- use-after-free
[1] https://sashiko.dev/#/bug/linux-e4eef44b-8ad5-49c0-ac52-81edebd4fd36
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119171232.1616316-1-mika.westerberg@linux.intel.com?part=1
next prev parent reply other threads:[~2026-11-19 17:32 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 17:12 [PATCH 00/18] thunderbolt: Add support for shared buffering Mika Westerberg
2026-11-19 17:12 ` [PATCH 01/18] thunderbolt: Avoid leaking of DMA tunnel after XDomain removal Mika Westerberg
2026-11-19 17:32 ` sashiko-bot [this message]
2026-11-19 17:12 ` [PATCH 02/18] thunderbolt: Tear down DMA tunnels on every " Mika Westerberg
2026-11-19 17:34 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 03/18] thunderbolt: Delay re-pairing DP IN/OUT if DPRX negotiation fails Mika Westerberg
2026-11-19 17:26 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 04/18] thunderbolt: Call DP tunnel activation callback with tb->lock held Mika Westerberg
2026-11-19 17:28 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 05/18] thunderbolt: Re-apply Alpine/Titan Ridge flow on resume Mika Westerberg
2026-11-19 17:35 ` sashiko-bot
2026-11-20 6:33 ` Mika Westerberg
2026-11-19 17:12 ` [PATCH 06/18] thunderbolt: Return -ESHUTDOWN when control channel is not running Mika Westerberg
2026-11-19 17:25 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 07/18] thunderbolt: Add usb4_port_hotplug_disable() Mika Westerberg
2026-11-19 17:22 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 08/18] thunderbolt: Move tb_plug_events_active() before tb_switch_reset_host() Mika Westerberg
2026-11-19 17:25 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 09/18] thunderbolt: Add tb_port_state_is_up() Mika Westerberg
2026-11-19 17:22 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 10/18] thunderbolt: Split host router port reset into a separate function Mika Westerberg
2026-11-19 17:22 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 11/18] thunderbolt: Reset topology after suspend-to-disk Mika Westerberg
2026-11-19 17:44 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 12/18] thunderbolt: Drop tunnel discovery without HopID allocation Mika Westerberg
2026-11-19 17:26 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 13/18] thunderbolt: Always take domain lock when tb_tunnel_put() is called Mika Westerberg
2026-11-19 17:34 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 14/18] thunderbolt: Assign domain to the routers in KUnit tests Mika Westerberg
2026-11-19 17:26 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 15/18] thunderbolt: Rework tunnel credit allocation Mika Westerberg
2026-11-19 17:43 ` sashiko-bot
2026-11-20 6:54 ` Mika Westerberg
2026-11-19 17:12 ` [PATCH 16/18] thunderbolt: Add support for shared flow control Mika Westerberg
2026-11-19 17:34 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 17/18] thunderbolt: Use restricted shared flow control for DMA tunnels on intra-domain links Mika Westerberg
2026-11-19 17:32 ` sashiko-bot
2026-11-19 17:12 ` [PATCH 18/18] thunderbolt: Add KUnit tests for shared buffering Mika Westerberg
2026-11-19 17:28 ` sashiko-bot
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=sashiko-outbox-223699@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=sashiko-reviews@lists.linux.dev \
/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.