Skip to content

Commit 1f44328

Browse files
melverKAGA-KOKO
authored andcommitted
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: 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]
1 parent eb73876 commit 1f44328

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

include/linux/compiler_types.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,14 @@ struct ftrace_likely_data {
171171
*/
172172
#define noinline_for_stack noinline
173173

174-
#ifdef CONFIG_KASAN
174+
/*
175+
* Sanitizer helper attributes: Because using __always_inline and
176+
* __no_sanitize_* conflict, provide helper attributes that will either expand
177+
* to __no_sanitize_* in compilation units where instrumentation is enabled
178+
* (__SANITIZE_*__), or __always_inline in compilation units without
179+
* instrumentation (__SANITIZE_*__ undefined).
180+
*/
181+
#ifdef __SANITIZE_ADDRESS__
175182
/*
176183
* We can't declare function 'inline' because __no_sanitize_address conflicts
177184
* with inlining. Attempt to inline it may cause a build failure.
@@ -186,10 +193,6 @@ struct ftrace_likely_data {
186193

187194
#define __no_kcsan __no_sanitize_thread
188195
#ifdef __SANITIZE_THREAD__
189-
/*
190-
* Rely on __SANITIZE_THREAD__ instead of CONFIG_KCSAN, to avoid not inlining in
191-
* compilation units where instrumentation is disabled.
192-
*/
193196
# define __no_kcsan_or_inline __no_kcsan notrace __maybe_unused
194197
# define __no_sanitize_or_inline __no_kcsan_or_inline
195198
#else

0 commit comments

Comments
 (0)