diff mbox series

[069/118] kasan: use error_report_end tracepoint

Message ID 20210226011951.dz9805GbD%akpm@linux-foundation.org (mailing list archive)
State New
Headers show
Series [001/118] mm: make pagecache tagged lookups return only head pages | expand

Commit Message

Andrew Morton Feb. 26, 2021, 1:19 a.m. UTC
From: Alexander Potapenko <glider@google.com>
Subject: kasan: use error_report_end tracepoint

Make it possible to trace KASAN error reporting.  A good usecase is
watching for trace events from the userspace to detect and process memory
corruption reports from the kernel.

Link: https://lkml.kernel.org/r/20210121131915.1331302-4-glider@google.com
Signed-off-by: Alexander Potapenko <glider@google.com>
Suggested-by: Marco Elver <elver@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

 mm/kasan/report.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series


--- a/mm/kasan/report.c~kasan-use-error_report_end-tracepoint
+++ a/mm/kasan/report.c
@@ -25,6 +25,7 @@ 
 #include <linux/module.h>
 #include <linux/sched/task_stack.h>
 #include <linux/uaccess.h>
+#include <trace/events/error_report.h>
 #include <asm/sections.h>
@@ -84,8 +85,9 @@  static void start_report(unsigned long *
-static void end_report(unsigned long *flags)
+static void end_report(unsigned long *flags, unsigned long addr)
+	trace_error_report_end(ERROR_DETECTOR_KASAN, addr);
 	spin_unlock_irqrestore(&report_lock, *flags);
@@ -355,7 +357,7 @@  void kasan_report_invalid_free(void *obj
 	print_address_description(object, tag);
-	end_report(&flags);
+	end_report(&flags, (unsigned long)object);
 static void __kasan_report(unsigned long addr, size_t size, bool is_write,
@@ -401,7 +403,7 @@  static void __kasan_report(unsigned long
-	end_report(&flags);
+	end_report(&flags, addr);
 bool kasan_report(unsigned long addr, size_t size, bool is_write,