[PATCH] irq_work: Make irq_work_queue() NMI-safe again

From: Peter Zijlstra
Date: Tue Jun 08 2021 - 13:59:38 EST


On Tue, Jun 08, 2021 at 07:51:02PM +0200, Peter Zijlstra wrote:
> On Wed, Mar 31, 2021 at 02:32:02PM +0800, qiang.zhang@xxxxxxxxxxxxx wrote:
>
> > @@ -70,6 +70,9 @@ bool irq_work_queue(struct irq_work *work)
> > if (!irq_work_claim(work))
> > return false;
> >
> > + /*record irq_work call stack in order to print it in KASAN reports*/
> > + kasan_record_aux_stack(work);
> > +
> > /* Queue the entry and raise the IPI if needed. */
> > preempt_disable();
> > __irq_work_queue_local(work);
>
> Thanks for the Cc :/ Also NAK.
>
> I shall go revert this instantly. KASAN is not NMI safe, while
> irq_work_queue() is very carefully crafted to be exactly that.

The below goes in tip/perf/urgent ASAP.

---
Subject: irq_work: Make irq_work_queue() NMI-safe again
From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Date: Tue Jun 8 19:54:15 CEST 2021

Someone carelessly put NMI unsafe code in irq_work_queue(), breaking
just about every single user. Also, someone has a terrible comment
style.

Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
kernel/irq_work.c | 3 ---
1 file changed, 3 deletions(-)

--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -70,9 +70,6 @@ bool irq_work_queue(struct irq_work *wor
if (!irq_work_claim(work))
return false;

- /*record irq_work call stack in order to print it in KASAN reports*/
- kasan_record_aux_stack(work);
-
/* Queue the entry and raise the IPI if needed. */
preempt_disable();
__irq_work_queue_local(work);