linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] irq_work: Make irq_work_queue_on() NMI-safe again
@ 2022-04-27 13:55 Jun Miao
  2022-04-28  9:24 ` Peter Zijlstra
  0 siblings, 1 reply; 2+ messages in thread
From: Jun Miao @ 2022-04-27 13:55 UTC (permalink / raw)
  To: elver, dvyukov, ryabinin.a.a, peterz
  Cc: bigeasy, qiang1.zhang, andreyknvl, kasan-dev, linux-kernel, akpm,
	jun.miao

We should not put NMI unsafe code in irq_work_queue_on().

The KASAN of kasan_record_aux_stack_noalloc() is not NMI safe. Because which
will call the spinlock. While the irq_work_queue_on() is also very carefully
crafted to be exactly that.
When unable CONFIG_SMP or local CPU, the irq_work_queue_on() is even same to
irq_work_queue(). So delete KASAN instantly.

Fixes: e2b5bcf9f5ba ("irq_work: record irq_work_queue() call stack")
Suggested by: "Huang, Ying" <ying.huang@intel.com>
Signed-off-by: Jun Miao <jun.miao@intel.com>
Acked-by: Marco Elver <elver@google.com>
---
 kernel/irq_work.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index 7afa40fe5cc4..e7f48aa8d8af 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -20,7 +20,6 @@
 #include <linux/smp.h>
 #include <linux/smpboot.h>
 #include <asm/processor.h>
-#include <linux/kasan.h>
 
 static DEFINE_PER_CPU(struct llist_head, raised_list);
 static DEFINE_PER_CPU(struct llist_head, lazy_list);
@@ -137,8 +136,6 @@ bool irq_work_queue_on(struct irq_work *work, int cpu)
 	if (!irq_work_claim(work))
 		return false;
 
-	kasan_record_aux_stack_noalloc(work);
-
 	preempt_disable();
 	if (cpu != smp_processor_id()) {
 		/* Arch remote IPI send/receive backend aren't NMI safe */
-- 
2.32.0


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

* Re: [PATCH v2] irq_work: Make irq_work_queue_on() NMI-safe again
  2022-04-27 13:55 [PATCH v2] irq_work: Make irq_work_queue_on() NMI-safe again Jun Miao
@ 2022-04-28  9:24 ` Peter Zijlstra
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2022-04-28  9:24 UTC (permalink / raw)
  To: Jun Miao
  Cc: elver, dvyukov, ryabinin.a.a, bigeasy, qiang1.zhang, andreyknvl,
	kasan-dev, linux-kernel, akpm

On Wed, Apr 27, 2022 at 09:55:49PM +0800, Jun Miao wrote:
> We should not put NMI unsafe code in irq_work_queue_on().

Why not, irq_work_queue_on() is not NMI safe. Only irq_work_queue() is.


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

end of thread, other threads:[~2022-04-28  9:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27 13:55 [PATCH v2] irq_work: Make irq_work_queue_on() NMI-safe again Jun Miao
2022-04-28  9:24 ` Peter Zijlstra

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).