kasan: Respect /proc/sys/kernel/traceoff_on_warning
Subsystems (2)
PATCH 1/1 kasan: Respect /proc/sys/kernel/traceoff_on_warning
After much waiting I finally reproduced a KASAN issue, only to find my trace-buffer empty of useful information because it got spooled out :/
Make kasan_report honour the /proc/sys/kernel/traceoff_on_warning interface.
--- mm/kasan/report.c | 2 ++ 1 file changed, 2 insertions(+)
mm/kasan/report.c +2 -0
@@ -300,6 +300,8 @@ void kasan_report(unsigned long addr, size_t size,if (likely (!kasan_report_enabled ()))return ; +disable_trace_on_warning (); + info.access_addr = (void *)addr; info.access_size = size; info.is_write = is_write;
Quoted 9 lines · Peter Zijlstra
After much waiting I finally reproduced a KASAN issue, only to find my trace-buffer empty of useful information because it got spooled out :/
Make
kasan_reporthonour the/proc/sys/kernel/traceoff_on_warninginterface.Signed-off-by Peter Zijlstra (Intel) <[email protected]>---
Seems to compile better when you add the required header files...
mm/kasan/report.c | 3 +++ 1 file changed, 3 insertions(+)
mm/kasan/report.c +3 -0
@@ -24,6 +24,7 @@#include <linux/types.h> #include <linux/kasan.h> #include <linux/module.h> +#include <linux/ftrace.h> #include <asm/sections.h>
@@ -300,6 +301,8 @@ void kasan_report(unsigned long addr, size_t size,if (likely (!kasan_report_enabled ()))return ; +disable_trace_on_warning (); + info.access_addr = (void *)addr; info.access_size = size; info.is_write = is_write;
Alexander Potapenko
reviewerQuoted 29 lines · Peter Zijlstra
Quoted 9 lines · Peter Zijlstra
After much waiting I finally reproduced a KASAN issue, only to find my trace-buffer empty of useful information because it got spooled out :/
Make
kasan_reporthonour the/proc/sys/kernel/traceoff_on_warninginterface.Signed-off-by Peter Zijlstra (Intel) <[email protected]>---
Seems to compile better when you add the required header files...
mm/kasan/report.c | 3 +++ 1 file changed, 3 insertions(+)mm/kasan/report.c +1
-0@@ -24,6 +24,7 @@#include <linux/types.h> #include <linux/kasan.h> #include <linux/module.h> +#include <linux/ftrace.h> #include <asm/sections.h>
mm/kasan/report.c void kasan_report(unsigned long addr, size_t size, · line 305
Quoted 5 lines
mm/kasan/report.c +2
-0@@ -300,6 +301,8 @@ void kasan_report(unsigned long addr, size_t size,if (likely (!kasan_report_enabled ()))return ; +disable_trace_on_warning (); +
Who is going to enable tracing back after we're done? Note that KASAN errors are not fatal, and the first one may possibly occur quite early.
Quoted 3 lines
mm/kasan/report.c +0
-0info.access_addr = (void *)addr; info.access_size = size; info.is_write = is_write;
Signature · 10 lines
Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Straße, 33 80636 München Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg
Quoted 7 lines · Alexander Potapenko
mm/kasan/report.c void kasan_report(unsigned long addr, size_t size, · line 305
Quoted 6 lines
mm/kasan/report.c +2
-0@@ -300,6 +301,8 @@ void kasan_report(unsigned long addr, size_t size,if (likely (!kasan_report_enabled ()))return ; +disable_trace_on_warning (); +Who is going to enable tracing back after we're done?
The user..
Quoted 2 lines
Note that KASAN errors are not fatal, and the first one may possibly occur quite early.
WARN*() isn't fatal either, and it does the same thing. Note that traceoff_on_warning is default disabled. You have to explicitly request this.
Alexander Potapenko
reviewerQuoted 10 lines · Peter Zijlstra
Quoted 7 lines · Alexander Potapenko
mm/kasan/report.c void kasan_report(unsigned long addr, size_t size, · line 305
Quoted 6 lines
mm/kasan/report.c +2
-0@@ -300,6 +301,8 @@ void kasan_report(unsigned long addr, size_t size,if (likely (!kasan_report_enabled ()))return ; +disable_trace_on_warning (); +Who is going to enable tracing back after we're done?
Quoted 8 lines
The user..
Quoted 2 lines
Note that KASAN errors are not fatal, and the first one may possibly occur quite early.
WARN*() isn't fatal either, and it does the same thing. Note that
traceoff_on_warningis default disabled. You have to explicitly request this.
Ah, that makes sense. Sorry, I wasn't aware of that interface before.
Signature · 10 lines
Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Straße, 33 80636 München Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg
Quoted 8 lines · Peter Zijlstra
After much waiting I finally reproduced a KASAN issue, only to find my trace-buffer empty of useful information because it got spooled out :/
Make
kasan_reporthonour the/proc/sys/kernel/traceoff_on_warninginterface.Signed-off-by Peter Zijlstra (Intel) <[email protected]>
Quoted 17 lines
--- mm/kasan/report.c | 2 ++ 1 file changed, 2 insertions(+)mm/kasan/report.c +2
-0@@ -300,6 +300,8 @@ void kasan_report(unsigned long addr, size_t size,if (likely (!kasan_report_enabled ()))return ; +disable_trace_on_warning (); + info.access_addr = (void *)addr; info.access_size = size; info.is_write = is_write;
Signature · 10 lines
Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Straße, 33 80636 München Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg
kbuild test robot
build botreproduce:
Hi Peter,
[auto build test ERROR on mmotm/master]
[also build test ERROR on v4.10-rc5 next-20170125]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Peter-Zijlstra/kasan-Respect-proc-sys-kernel-traceoff_on_warning/20170125-230535 base: git://git.cmpxchg.org/linux-mmotm.git master config: x86_64-randconfig-x008-201704 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
All errors (new ones prefixed by >>):
mm/kasan/report.c: In function 'kasan_report':
>> mm/kasan/report.c:303:2: error: implicit declaration of function 'disable_trace_on_warning' [-Werror=implicit-function-declaration]
disable_trace_on_warning();
^~~~~~~~~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +/disable_trace_on_warning +303 mm/kasan/report.c
297 {
298 struct kasan_access_info info;
299
300 if (likely(!kasan_report_enabled()))
301 return;
302
> 303 disable_trace_on_warning();
304
305 info.access_addr = (void *)addr;
306 info.access_size = size;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v2 1/1 kasan: Respect /proc/sys/kernel/traceoff_on_warning
In reply to Peter ZijlstraFrom: Peter Zijlstra <[email protected]>
After much waiting I finally reproduced a KASAN issue, only to find my trace-buffer empty of useful information because it got spooled out :/
Make kasan_report honour the /proc/sys/kernel/traceoff_on_warning interface.
--- mm/kasan/report.c | 3 +++ 1 file changed, 3 insertions(+)
mm/kasan/report.c +3 -0
@@ -13,6 +13,7 @@* */ +#include <linux/ftrace.h> #include <linux/kernel.h> #include <linux/mm.h> #include <linux/printk.h>
@@ -300,6 +301,8 @@ void kasan_report(unsigned long addr, size_t size,if (likely (!kasan_report_enabled ()))return ; +disable_trace_on_warning (); + info.access_addr = (void *)addr; info.access_size = size; info.is_write = is_write;
Signature · 7 lines
2.10.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · On Wed, 25 Jan 2017 15:35:32 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 7 lines · Alexander Potapenko
mm/kasan/report.c void kasan_report(unsigned long addr, size_t size, · line 305
Quoted 6 lines
mm/kasan/report.c +2
-0@@ -300,6 +301,8 @@ void kasan_report(unsigned long addr, size_t size,if (likely (!kasan_report_enabled ()))return ; +disable_trace_on_warning (); +Who is going to enable tracing back after we're done?
The user..
Yep,
# echo 1 > /sys/kernel/debug/tracing/tracing_on
Re-enables tracing.
-- Steve
Quoted 7 lines
Quoted 3 lines
Note that KASAN errors are not fatal, and the first one may possibly occur quite early.
WARN*() isn't fatal either, and it does the same thing. Note that
traceoff_on_warningis default disabled. You have to explicitly request this.