]> git.baikalelectronics.ru Git - kernel.git/commitdiff
x86: kmsan: disable instrumentation of unsupported code
authorAlexander Potapenko <glider@google.com>
Thu, 15 Sep 2022 15:04:06 +0000 (17:04 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 3 Oct 2022 21:03:24 +0000 (14:03 -0700)
Instrumenting some files with KMSAN will result in kernel being unable to
link, boot or crashing at runtime for various reasons (e.g.  infinite
recursion caused by instrumentation hooks calling instrumented code
again).

Completely omit KMSAN instrumentation in the following places:
 - arch/x86/boot and arch/x86/realmode/rm, as KMSAN doesn't work for i386;
 - arch/x86/entry/vdso, which isn't linked with KMSAN runtime;
 - three files in arch/x86/kernel - boot problems;
 - arch/x86/mm/cpu_entry_area.c - recursion.

Link: https://lkml.kernel.org/r/20220915150417.722975-33-glider@google.com
Signed-off-by: Alexander Potapenko <glider@google.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Eric Biggers <ebiggers@kernel.org>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Marco Elver <elver@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/x86/boot/Makefile
arch/x86/boot/compressed/Makefile
arch/x86/entry/vdso/Makefile
arch/x86/kernel/Makefile
arch/x86/kernel/cpu/Makefile
arch/x86/mm/Makefile
arch/x86/realmode/rm/Makefile

index ffec8bb01ba8c20372b8cf4a37bd6810f054d0cc..9860ca5979f8aa508ced8ff09db0632c2e3f7dcc 100644 (file)
@@ -12,6 +12,7 @@
 # Sanitizer runtimes are unavailable and cannot be linked for early boot code.
 KASAN_SANITIZE                 := n
 KCSAN_SANITIZE                 := n
+KMSAN_SANITIZE                 := n
 OBJECT_FILES_NON_STANDARD      := y
 
 # Kernel does not boot with kcov instrumentation here.
index 35ce1a64068b76d2871a31c65f28324ecf18f17f..3a261abb6d158d62c9592f115ec39542d23ca2ab 100644 (file)
@@ -20,6 +20,7 @@
 # Sanitizer runtimes are unavailable and cannot be linked for early boot code.
 KASAN_SANITIZE                 := n
 KCSAN_SANITIZE                 := n
+KMSAN_SANITIZE                 := n
 OBJECT_FILES_NON_STANDARD      := y
 
 # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
index 12f6c4d714cd63c7579066b7201aa2d33440cc69..ce4eb7e44e5b8f12e0c9bb4472e823086cc61d5f 100644 (file)
@@ -11,6 +11,9 @@ include $(srctree)/lib/vdso/Makefile
 
 # Sanitizer runtimes are unavailable and cannot be linked here.
 KASAN_SANITIZE                 := n
+KMSAN_SANITIZE_vclock_gettime.o := n
+KMSAN_SANITIZE_vgetcpu.o       := n
+
 UBSAN_SANITIZE                 := n
 KCSAN_SANITIZE                 := n
 OBJECT_FILES_NON_STANDARD      := y
index a20a5ebfacd73f772249b986c55f3e5f5e15a044..ac564c5d7b1f066c9779ed242169091be211da65 100644 (file)
@@ -33,6 +33,8 @@ KASAN_SANITIZE_sev.o                                  := n
 # With some compiler versions the generated code results in boot hangs, caused
 # by several compilation units. To be safe, disable all instrumentation.
 KCSAN_SANITIZE := n
+KMSAN_SANITIZE_head$(BITS).o                           := n
+KMSAN_SANITIZE_nmi.o                                   := n
 
 # If instrumentation of this dir is enabled, boot hangs during first second.
 # Probably could be more selective here, but note that files related to irqs,
index 9661e3e802be56e937f137e467b7d4a1669d4410..f10a921ee75658980b92d0d81238d9c16fb642ce 100644 (file)
@@ -12,6 +12,7 @@ endif
 # If these files are instrumented, boot hangs during the first second.
 KCOV_INSTRUMENT_common.o := n
 KCOV_INSTRUMENT_perf_event.o := n
+KMSAN_SANITIZE_common.o := n
 
 # As above, instrumenting secondary CPU boot code causes boot hangs.
 KCSAN_SANITIZE_common.o := n
index 829c1409ffbde12dbc77057c19e908bdc6801d51..afb6f7187dad0c8f1e1a121ef4e49f33d1c30fd9 100644 (file)
@@ -14,6 +14,8 @@ KASAN_SANITIZE_pgprot.o               := n
 # Disable KCSAN entirely, because otherwise we get warnings that some functions
 # reference __initdata sections.
 KCSAN_SANITIZE := n
+# Avoid recursion by not calling KMSAN hooks for CEA code.
+KMSAN_SANITIZE_cpu_entry_area.o := n
 
 ifdef CONFIG_FUNCTION_TRACER
 CFLAGS_REMOVE_mem_encrypt.o            = -pg
index 83f1b6a56449fedd03d0976a63e2e5ecd886d775..f614009d3e4e2eb944862bacb260b0da088f5c0a 100644 (file)
@@ -10,6 +10,7 @@
 # Sanitizer runtimes are unavailable and cannot be linked here.
 KASAN_SANITIZE                 := n
 KCSAN_SANITIZE                 := n
+KMSAN_SANITIZE                 := n
 OBJECT_FILES_NON_STANDARD      := y
 
 # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.