Commit 1f44328e authored by Marco Elver's avatar Marco Elver Committed by Thomas Gleixner

compiler_types.h, kasan: Use __SANITIZE_ADDRESS__ instead of CONFIG_KASAN to decide inlining

Use __always_inline in compilation units that have instrumentation
disabled (KASAN_SANITIZE_foo.o := n) for KASAN, like it is done for
KCSAN.

Also, add common documentation for KASAN and KCSAN explaining the
attribute.

 [ bp: Massage commit message. ]
Signed-off-by: default avatarMarco Elver <elver@google.com>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarWill Deacon <will@kernel.org>
Link: https://lkml.kernel.org/r/20200521142047.169334-12-elver@google.com

parent eb73876c
...@@ -171,7 +171,14 @@ struct ftrace_likely_data { ...@@ -171,7 +171,14 @@ struct ftrace_likely_data {
*/ */
#define noinline_for_stack noinline #define noinline_for_stack noinline
#ifdef CONFIG_KASAN /*
* Sanitizer helper attributes: Because using __always_inline and
* __no_sanitize_* conflict, provide helper attributes that will either expand
* to __no_sanitize_* in compilation units where instrumentation is enabled
* (__SANITIZE_*__), or __always_inline in compilation units without
* instrumentation (__SANITIZE_*__ undefined).
*/
#ifdef __SANITIZE_ADDRESS__
/* /*
* We can't declare function 'inline' because __no_sanitize_address conflicts * We can't declare function 'inline' because __no_sanitize_address conflicts
* with inlining. Attempt to inline it may cause a build failure. * with inlining. Attempt to inline it may cause a build failure.
...@@ -186,10 +193,6 @@ struct ftrace_likely_data { ...@@ -186,10 +193,6 @@ struct ftrace_likely_data {
#define __no_kcsan __no_sanitize_thread #define __no_kcsan __no_sanitize_thread
#ifdef __SANITIZE_THREAD__ #ifdef __SANITIZE_THREAD__
/*
* Rely on __SANITIZE_THREAD__ instead of CONFIG_KCSAN, to avoid not inlining in
* compilation units where instrumentation is disabled.
*/
# define __no_kcsan_or_inline __no_kcsan notrace __maybe_unused # define __no_kcsan_or_inline __no_kcsan notrace __maybe_unused
# define __no_sanitize_or_inline __no_kcsan_or_inline # define __no_sanitize_or_inline __no_kcsan_or_inline
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment