READ_ONCE_NOCHECK() is already used by KASAN to ignore memory accesses from e.g. stack unwinders. Define READ_ONCE_NOCHECK() for KMSAN so that it returns initialized values. This helps defeat false positives from leftover stack contents. Signed-off-by: Alexander Potapenko <glider@xxxxxxxxxx> To: Alexander Potapenko <glider@xxxxxxxxxx> Cc: Mark Rutland <mark.rutland@xxxxxxx> Cc: Vegard Nossum <vegard.nossum@xxxxxxxxxx> Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx> Cc: Marco Elver <elver@xxxxxxxxxx> Cc: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Cc: linux-mm@xxxxxxxxx --- v3: - removed unnecessary #ifdef as requested by Mark Rutland v4: - added an #include as requested by Marco Elver Change-Id: Ib38369ba038ab3b581d8e45b81036c3304fb79cb --- include/linux/compiler.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 5e88e7e33abe..de7942423836 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -255,6 +255,7 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s */ #include <asm/barrier.h> #include <linux/kasan-checks.h> +#include <linux/kmsan-checks.h> #define __READ_ONCE(x, check) \ ({ \ @@ -270,9 +271,9 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s /* * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need - * to hide memory access from KASAN. + * to hide memory access from KASAN or KMSAN. */ -#define READ_ONCE_NOCHECK(x) __READ_ONCE(x, 0) +#define READ_ONCE_NOCHECK(x) KMSAN_INIT_VALUE(__READ_ONCE(x, 0)) static __no_kasan_or_inline unsigned long read_word_at_a_time(const void *addr) -- 2.24.1.735.g03f4e72817-goog