linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: spectre-v2: fix smp_processor_id() warning
@ 2022-06-22  6:49 Tetsuo Handa
  2022-06-22 11:21 ` Russell King (Oracle)
  2022-06-22 13:50 ` Marc Zyngier
  0 siblings, 2 replies; 10+ messages in thread
From: Tetsuo Handa @ 2022-06-22  6:49 UTC (permalink / raw)
  To: Russell King, Tony Lindgren; +Cc: LKML, Linux ARM

syzbot complains smp_processor_id() from harden_branch_predictor()
 from page fault path [1]. Explicitly disable preemption and use
raw_smp_processor_id().

Link: https://syzkaller.appspot.com/bug?extid=a7ee43e564223f195c84 [1]
Reported-by: syzbot <syzbot+a7ee43e564223f195c84@syzkaller.appspotmail.com>
Fixes: f5fe12b1eaee220c ("ARM: spectre-v2: harden user aborts in kernel space")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
This patch is completely untested.

 arch/arm/include/asm/system_misc.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/system_misc.h b/arch/arm/include/asm/system_misc.h
index 98b37340376b..a92446769acd 100644
--- a/arch/arm/include/asm/system_misc.h
+++ b/arch/arm/include/asm/system_misc.h
@@ -20,8 +20,11 @@ typedef void (*harden_branch_predictor_fn_t)(void);
 DECLARE_PER_CPU(harden_branch_predictor_fn_t, harden_branch_predictor_fn);
 static inline void harden_branch_predictor(void)
 {
-	harden_branch_predictor_fn_t fn = per_cpu(harden_branch_predictor_fn,
-						  smp_processor_id());
+	harden_branch_predictor_fn_t fn;
+
+	preempt_disable_notrace();
+	fn = per_cpu(harden_branch_predictor_fn, raw_smp_processor_id());
+	preempt_enable_no_resched_notrace();
 	if (fn)
 		fn();
 }
-- 
2.18.4

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-07-15 14:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-22  6:49 [PATCH] ARM: spectre-v2: fix smp_processor_id() warning Tetsuo Handa
2022-06-22 11:21 ` Russell King (Oracle)
2022-06-22 13:31   ` Tetsuo Handa
2022-06-22 13:50 ` Marc Zyngier
2022-06-22 14:04   ` Russell King (Oracle)
2022-06-22 15:02     ` Tetsuo Handa
2022-06-24  5:39       ` Tetsuo Handa
2022-07-15 13:09         ` [PATCH v2] " Tetsuo Handa
2022-07-15 13:36           ` Russell King (Oracle)
2022-07-15 14:07             ` Tetsuo Handa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).