Skip to content

Commit

Permalink
irq_work: record irq_work_queue() call stack
Browse files Browse the repository at this point in the history
Add the irq_work_queue() call stack into the KASAN auxiliary stack in
order to improve KASAN reports.  this will let us know where the irq work
be queued.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Zqiang <[email protected]>
Reviewed-by: Dmitry Vyukov <[email protected]>
Acked-by: Andrey Konovalov <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: Matthias Brugger <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Walter Wu <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Zqiang1211 authored and torvalds committed Apr 30, 2021
1 parent 99734b5 commit e2b5bcf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kernel/irq_work.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <linux/notifier.h>
#include <linux/smp.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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -98,6 +101,8 @@ bool irq_work_queue_on(struct irq_work *work, int cpu)
if (!irq_work_claim(work))
return false;

kasan_record_aux_stack(work);

preempt_disable();
if (cpu != smp_processor_id()) {
/* Arch remote IPI send/receive backend aren't NMI safe */
Expand Down

0 comments on commit e2b5bcf

Please sign in to comment.