Skip to content

Commit

Permalink
compiler_types.h, kasan: Use __SANITIZE_ADDRESS__ instead of CONFIG_K…
Browse files Browse the repository at this point in the history
…ASAN 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: Marco Elver <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Acked-by: Will Deacon <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
melver authored and KAGA-KOKO committed Jun 11, 2020
1 parent eb73876 commit 1f44328
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions include/linux/compiler_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,14 @@ struct ftrace_likely_data {
*/
#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
* with inlining. Attempt to inline it may cause a build failure.
Expand All @@ -186,10 +193,6 @@ struct ftrace_likely_data {

#define __no_kcsan __no_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_sanitize_or_inline __no_kcsan_or_inline
#else
Expand Down

0 comments on commit 1f44328

Please sign in to comment.