From: sashiko-bot@kernel.org
To: "Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>
Cc: linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] irqchip/riscv-aplic: fix asynchronous probing
Date: Mon, 12 Oct 2026 07:43:03 +0000 [thread overview]
Message-ID: <sashiko-outbox-167805@kernel.org> (raw)
In-Reply-To: <20261012-aplic-async-probe-v1-1-4c2c4f5b0916@mobileye.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] irqchip/riscv-aplic: unconditional atomic write to __ro_after_init variable in probe
--
commit 226fcd5ec01da9df7f8352eacfc1a2ef6a9d054e
Author: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
irqchip/riscv-aplic: fix asynchronous probing
This commit addresses a race condition during asynchronous probing of multiple
APLIC instances. It prevents a double list_add warning in syscore registration
by replacing a boolean flag with an atomic counter.
> diff --git a/drivers/irqchip/irq-riscv-aplic-main.c b/drivers/irqchip/irq-riscv-aplic-main.c
> index d9afb6ae98cf5..db15ec8a2d346 100644
> --- a/drivers/irqchip/irq-riscv-aplic-main.c
> +++ b/drivers/irqchip/irq-riscv-aplic-main.c
[ ... ]
> @@ -116,14 +116,12 @@ static struct syscore aplic_syscore = {
> .ops = &aplic_syscore_ops,
> };
>
> -static bool aplic_syscore_registered __ro_after_init;
> +static atomic_t aplic_syscore_registered = ATOMIC_INIT(0) __ro_after_init;
>
> static void aplic_syscore_init(void)
> {
> - if (!aplic_syscore_registered) {
> + if (!atomic_fetch_inc(&aplic_syscore_registered))
[Severity: High]
Does this unconditional atomic write risk a page fault crash?
Since aplic_syscore_registered is marked with __ro_after_init, calling
atomic_fetch_inc() performs an unconditional read-modify-write operation on it.
If the platform driver's aplic_probe() executes after the kernel initialization
phase completes (for instance, via deferred probing or a manual sysfs unbind
and bind), writing to this read-only page will trigger a fatal Store/AMO access
page fault.
While a first probe post-init would have crashed previously as well, this
change degrades the behavior. Previously, a second late probe would just read
true and skip the write entirely, whereas now it unconditionally writes and
crashes.
> register_syscore(&aplic_syscore);
> - aplic_syscore_registered = true;
> - }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012-aplic-async-probe-v1-1-4c2c4f5b0916@mobileye.com?part=1
prev parent reply other threads:[~2026-10-12 7:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 7:34 [PATCH] irqchip/riscv-aplic: fix asynchronous probing Vladimir Kondratiev
2026-10-12 7:43 ` sashiko-bot [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=sashiko-outbox-167805@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vladimir.kondratiev@mobileye.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