FROMGIT: kfence: use error_report_end tracepoint

Make it possible to trace KFENCE 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-3-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: Vlastimil Babka <vbabka@suse.cz>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Bug: 177201466
(cherry picked from commit 2eb9559621418b844b29d2b56d9962ac019f600b
    https://github.com/hnaz/linux-mm v5.11-rc4-mmots-2021-01-21-20-10)
Test: CONFIG_KFENCE_KUNIT_TEST=y passes on Cuttlefish
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: I991cd1eee48d107bcdf5e1c0d9194e6a386b9bdf
This commit is contained in:
Alexander Potapenko
2021-01-22 09:18:44 +00:00
committed by Alistair Delva
parent 8d1fea4a24
commit fc3ec019c8

View File

@@ -14,6 +14,7 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/stacktrace.h> #include <linux/stacktrace.h>
#include <linux/string.h> #include <linux/string.h>
#include <trace/events/error_report.h>
#include <asm/kfence.h> #include <asm/kfence.h>
@@ -246,6 +247,7 @@ void kfence_report_error(unsigned long address, bool is_write, struct pt_regs *r
show_regs(regs); show_regs(regs);
else else
dump_stack_print_info(KERN_ERR); dump_stack_print_info(KERN_ERR);
trace_error_report_end(ERROR_DETECTOR_KFENCE, address);
pr_err("==================================================================\n"); pr_err("==================================================================\n");
lockdep_on(); lockdep_on();