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 3/3] hwspinlock: add low level debug capabilities
Date: Sun, 26 Jul 2026 23:26:39 +0200 [thread overview]
Message-ID: <amZ7j59YnuQBaz2m@ninjato> (raw)
In-Reply-To: <20260718163024.1726-4-wsa+renesas@sang-engineering.com>
> > +static struct hwspinlock *hwspin_lock_ll_debug_get(u64 id)
> > +{
> > + struct hwspinlock *hwlock;
> > + unsigned long index = id;
>
> [Severity: Low]
> Does casting the u64 id to an unsigned long truncate the value on
> 32-bit architectures, causing operations to mistakenly target a different
> lock if the provided ID exceeds 32 bits?
Addressed in v5.
>
> > +
> > + rcu_read_lock();
> > + hwlock = xa_find(&hwspinlocks, &index, ULONG_MAX, XA_PRESENT);
>
> [Severity: Medium]
> Since xa_find() searches for the first present entry at or above the index
> and updates the index variable, will this silently operate on an
> unrelated active lock if the exact requested id is not present, instead
> of using xa_load() for an exact-ID lookup?
Addressed in v5.
> [Severity: Low]
> hwspin_lock_request_specific() expects an unsigned int id. Does passing
> the u64 id here silently truncate it on 64-bit architectures as well?
Addressed in v5.
> > +static int fops_trylock_raw_set(void *data, u64 id)
> > +{
> > + struct hwspinlock *hwlock = hwspin_lock_ll_debug_get(id);
> > +
> > + return hwlock ? hwspin_trylock_raw(hwlock) : -ENOENT;
> > +}
>
> [Severity: High]
> Do these raw debugfs accessors invoke memory-mapped I/O registers without
> ensuring the device's clocks and power domains are active?
>
> Since this interface explicitly allows operating on unrequested locks
> (which are likely powered off), can accessing the registers trigger an
> asynchronous external abort or synchronous bus fault on typical SoCs?
True but it is still a great debugging help. I extended the comment to
explain this potential problem.
> > + ret = hwspin_trylock(hwlock);
> > + if (ret != -EBUSY) {
> > + hwspin_lock_free(hwlock);
> > + return -EACCES;
> > + }
>
> [Severity: High]
> If the second hwspin_trylock() unexpectedly succeeds, it enters this
> error path and returns -EACCES. Since the first hwspin_trylock()
> disabled preemption and took the hardware lock, does returning here
> without calling hwspin_unlock() leave preemption permanently disabled?
Addressed in v5.
The rest were pre-existing UAF issues to be fixed in the next series.
prev parent reply other threads:[~2026-07-26 21:26 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
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 [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=amZ7j59YnuQBaz2m@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox