From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-renesas-soc@vger.kernel.org
Cc: Matthew Wilcox <willy@infradead.org>,
linux-kernel@vger.kernel.org,
Bjorn Andersson <andersson@kernel.org>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
linux-remoteproc@vger.kernel.org
Subject: Re: [PATCH v4 1/3] hwspinlock: Convert to XArray
Date: Sun, 26 Jul 2026 23:20:21 +0200 [thread overview]
Message-ID: <amZ6FReXAVUCO-pr@ninjato> (raw)
In-Reply-To: <20260718163024.1726-2-wsa+renesas@sang-engineering.com>
> [Severity: High]
> This is a pre-existing issue, but does dereferencing hwlock->bank->dev under
> rcu_read_lock() and later accessing hwlock->bank->num_locks after dropping it
> in of_hwspin_lock_get_id() lead to a Use-After-Free?
>
> While the XArray (and previously Radix Tree) lookup yields a pointer to
> hwlock, the hwlock structure is managed by devres (e.g. devm_kzalloc) which
> frees the memory synchronously on device unbind without waiting for an RCU
> grace period.
My next hwspinlock series will tackle the plenty of UAF issues.
> [Severity: High]
> This is a pre-existing issue, but does aborting here lead to dangling
> pointers in the XArray when devres subsequently frees the bank memory?
Ditto.
> > + xas_unlock(&xas);
> >
> > + ret = hwspin_lock_prepare(hwlock);
> > +
> > + xas_lock(&xas);
> > + if (ret < 0) {
> > + hwlock = NULL;
> > + xas_set_mark(&xas, HWSPINLOCK_UNUSED);
>
> [Severity: High]
> Can reusing the un-reset XA_STATE after dropping the XArray lock and sleeping
> in hwspin_lock_request_specific() lead to a Use-After-Free?
>
> This function drops the XArray lock and calls hwspin_lock_prepare(), which can
> sleep via pm_runtime_get_sync(). While sleeping, concurrent modifications to
> the XArray can cause internal nodes to be reallocated or freed.
>
> Upon waking, if hwspin_lock_prepare() fails, the function reacquires the lock
> and calls xas_set_mark(&xas, HWSPINLOCK_UNUSED) using the stale xas iterator,
> which might dereference the potentially freed xas.xa_node.
I fixed this in v5 to be sent soon.
next prev parent reply other threads:[~2026-07-26 21:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-18 16:30 [PATCH v4 0/3] hwspinlock: convert to XArray and add debug capabilities Wolfram Sang
2026-07-18 16:30 ` [PATCH v4 1/3] hwspinlock: Convert to XArray Wolfram Sang
2026-07-26 21:20 ` Wolfram Sang [this message]
2026-07-18 16:30 ` [PATCH v4 2/3] hwspinlock: add list of mailboxes to debugfs Wolfram Sang
2026-07-26 21:20 ` Wolfram Sang
2026-07-18 16:30 ` [PATCH v4 3/3] hwspinlock: add low level debug capabilities Wolfram Sang
2026-07-26 21:26 ` Wolfram Sang
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=amZ6FReXAVUCO-pr@ninjato \
--to=wsa+renesas@sang-engineering.com \
--cc=andersson@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=willy@infradead.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.