aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Potapenko <[email protected]>2024-04-26 11:16:22 +0200
committerAndrew Morton <[email protected]>2024-05-05 17:28:06 -0700
commit90d1f14cbb9ddbfc532e2da13bf6e0ed8320e792 (patch)
treedd78f792e9b5651b73387d6ccbdf1486df8a6846
parent2aaba39e783a10fd1368626bce6f618a6a2a78b0 (diff)
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: 5de0ce85f5a4 ("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]>
-rw-r--r--include/linux/compiler_types.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 2abaa3a825a9..8f8236317d5b 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -278,6 +278,17 @@ struct ftrace_likely_data {
# define __no_kcsan
#endif
+#ifdef __SANITIZE_MEMORY__
+/*
+ * Similarly to KASAN and KCSAN, KMSAN loses function attributes of inlined
+ * functions, therefore disabling KMSAN checks also requires disabling inlining.
+ *
+ * __no_sanitize_or_inline effectively prevents KMSAN from reporting errors
+ * within the function and marks all its outputs as initialized.
+ */
+# define __no_sanitize_or_inline __no_kmsan_checks notrace __maybe_unused
+#endif
+
#ifndef __no_sanitize_or_inline
#define __no_sanitize_or_inline __always_inline
#endif