Skip to content

Commit 90d1f14

Browse files
ramosian-gliderakpm00
authored andcommitted
kmsan: compiler_types: declare __no_sanitize_or_inline
It turned out that KMSAN instruments READ_ONCE_NOCHECK(), resulting in false positive reports, because __no_sanitize_or_inline enforced inlining. Properly declare __no_sanitize_or_inline under __SANITIZE_MEMORY__, so that it does not __always_inline the annotated function. Link: https://lkml.kernel.org/r/[email protected] Fixes: 5de0ce8 ("kmsan: mark noinstr as __no_sanitize_memory") Signed-off-by: Alexander Potapenko <[email protected]> Reported-by: [email protected] Link: https://lkml.kernel.org/r/[email protected] Cc: <[email protected]> Reviewed-by: Marco Elver <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Miguel Ojeda <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 2aaba39 commit 90d1f14

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/linux/compiler_types.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,17 @@ struct ftrace_likely_data {
278278
# define __no_kcsan
279279
#endif
280280

281+
#ifdef __SANITIZE_MEMORY__
282+
/*
283+
* Similarly to KASAN and KCSAN, KMSAN loses function attributes of inlined
284+
* functions, therefore disabling KMSAN checks also requires disabling inlining.
285+
*
286+
* __no_sanitize_or_inline effectively prevents KMSAN from reporting errors
287+
* within the function and marks all its outputs as initialized.
288+
*/
289+
# define __no_sanitize_or_inline __no_kmsan_checks notrace __maybe_unused
290+
#endif
291+
281292
#ifndef __no_sanitize_or_inline
282293
#define __no_sanitize_or_inline __always_inline
283294
#endif

0 commit comments

Comments
 (0)