From: Xie Yuanbin <xieyuanbin1@huawei.com>
To: <bigeasy@linutronix.de>
Cc: <akpm@linux-foundation.org>, <arnd@arndb.de>,
<brauner@kernel.org>, <kuninori.morimoto.gx@renesas.com>,
<liaohua4@huawei.com>, <lilinjie8@huawei.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux@armlinux.org.uk>,
<lorenzo.stoakes@oracle.com>, <marc.zyngier@arm.com>,
<pfalcato@suse.de>, <punitagrawal@gmail.com>, <rjw@rjwysocki.net>,
<rmk+kernel@armlinux.org.uk>, <rppt@kernel.org>,
<tony@atomide.com>, <vbabka@suse.cz>, <will@kernel.org>,
<xieyuanbin1@huawei.com>
Subject: Re: [PATCH v2 RESEND 1/2] ARM: spectre-v2: Fix potential missing mitigations
Date: Wed, 29 Oct 2025 10:41:51 +0800 [thread overview]
Message-ID: <20251029024151.6005-1-xieyuanbin1@huawei.com> (raw)
In-Reply-To: <20251028182052.nrRad87D@linutronix.de>
On Tue, 28 Oct 2025 17:20:05 +0100, Sebastian Andrzej Siewior wrote:
> If I apply both patches (of yours) then it sends a
> signal with disabled interrupts which breaks my PREEMPT_RT case.
I am not familiar with PREEMPT_RT yet and do not know that signals cannot
be sent with disabled interrupts and PREEMPT_RT=y.
I apologize for this.
On Tue, 28 Oct 2025 19:20:52 +0100, Sebastian Andrzej Siewior wrote:
> !LPAE does do_bad_area() -> __do_user_fault() and does not trigger the
> warning in harden_branch_predictor() because the interrupts are off.
> On PREEMPT_RT this leads to an error due to accessing spinlock_t from
> force_sig_fault() with disabled interrupts.
This seems to be a more serious bug, and may require another patch to
fix it. Not only !LPAE is affected, but LAPE=y is also affected:
do_translation_fault() -> do_bad_area() -> __do_user_fault()
This code path seems very easy to trigger.
> I guess the requirement is to invoke harden_branch_predictor() on the
> same CPU that triggered the page_fault, right? Couldn't we then move
> harden_branch_predictor() a little bit earlier, invoke it in the >=
> TASK_SIZE case and then enable interrupts if they were enabled?
>
> That would make me happy ;)
This seems to only fix the warning in harden_branch_predictor, but cannot
fix the issue of sending signals with disabled interrupts mentioned above.
What about adding:
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 09dde89a88ed..b9c9c80db109 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -182,6 +182,12 @@ __do_user_fault(unsigned long addr, unsigned int fsr, unsigned int sig,
int code, struct pt_regs *regs)
{
struct task_struct *tsk = current;
+ const bool save_irqs_disabled = irqs_disabled();
+
+ if (save_irqs_disabled) {
+ preempt_disable();
+ local_irq_enable();
+ }
if (addr > TASK_SIZE)
harden_branch_predictor();
@@ -207,6 +213,11 @@ __do_user_fault(unsigned long addr, unsigned int fsr, unsigned int sig,
tsk->thread.error_code = fsr;
tsk->thread.trap_no = 14;
force_sig_fault(sig, code, (void __user *)addr);
+
+ if (save_irqs_disabled) {
+ local_irq_disable();
+ preempt_enable_no_resched();
+ }
}
and the modification of patch 1 is still retained.
Xie Yuanbin
next prev parent reply other threads:[~2025-10-29 2:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 12:16 [PATCH v2 RESEND 1/2] ARM: spectre-v2: Fix potential missing mitigations Xie Yuanbin
2025-10-16 12:16 ` [PATCH v2 RESEND 2/2] ARM: mm: Optimize page_fault to reduce the impact of spectre-v2 bugfix Xie Yuanbin
2025-10-28 16:20 ` [PATCH v2 RESEND 1/2] ARM: spectre-v2: Fix potential missing mitigations Sebastian Andrzej Siewior
2025-10-28 16:28 ` Sebastian Andrzej Siewior
2025-10-28 18:20 ` Sebastian Andrzej Siewior
2025-10-29 2:41 ` Xie Yuanbin [this message]
2025-10-29 7:11 ` Sebastian Andrzej Siewior
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=20251029024151.6005-1-xieyuanbin1@huawei.com \
--to=xieyuanbin1@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=bigeasy@linutronix.de \
--cc=brauner@kernel.org \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=liaohua4@huawei.com \
--cc=lilinjie8@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lorenzo.stoakes@oracle.com \
--cc=marc.zyngier@arm.com \
--cc=pfalcato@suse.de \
--cc=punitagrawal@gmail.com \
--cc=rjw@rjwysocki.net \
--cc=rmk+kernel@armlinux.org.uk \
--cc=rppt@kernel.org \
--cc=tony@atomide.com \
--cc=vbabka@suse.cz \
--cc=will@kernel.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