]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr
authorMarco Elver <elver@google.com>
Thu, 4 Jun 2020 05:58:11 +0000 (07:58 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 15 Jun 2020 12:10:09 +0000 (14:10 +0200)
Adds the portable definitions for __no_sanitize_address, and
__no_sanitize_undefined, and subsequently changes noinstr to use the
attributes to disable instrumentation via KASAN or UBSAN.

Reported-by: syzbot+dc1fa714cb070b184db5@syzkaller.appspotmail.com
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Link: https://lore.kernel.org/lkml/000000000000d2474c05a6c938fe@google.com/
include/linux/compiler-clang.h
include/linux/compiler-gcc.h
include/linux/compiler_types.h

index ee37256ec8bdf1c7874adae0b60c1891178343bd..5e55302e3bf6068f23823f70a62ffd1f88af6a75 100644 (file)
 #define __no_sanitize_thread
 #endif
 
+#if __has_feature(undefined_behavior_sanitizer)
+/* GCC does not have __SANITIZE_UNDEFINED__ */
+#define __no_sanitize_undefined \
+               __attribute__((no_sanitize("undefined")))
+#else
+#define __no_sanitize_undefined
+#endif
+
 /*
  * Not all versions of clang implement the the type-generic versions
  * of the builtin overflow checkers. Fortunately, clang implements
index 7dd4e0349ef32197f706b0db66653d3b47ba3fa7..1c74464c80c65320a898a6f359790063eb15c3d7 100644 (file)
 #define __no_sanitize_thread
 #endif
 
+#if __has_attribute(__no_sanitize_undefined__)
+#define __no_sanitize_undefined __attribute__((no_sanitize_undefined))
+#else
+#define __no_sanitize_undefined
+#endif
+
 #if GCC_VERSION >= 50100
 #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
 #endif
index a8b4266084a157ccd7a5aa4fb12eaf73cb5fffa4..85b8d2370c244410e6888c53733fdd0d5caf2d73 100644 (file)
@@ -198,7 +198,8 @@ struct ftrace_likely_data {
 
 /* Section for code which can't be instrumented at all */
 #define noinstr                                                                \
-       noinline notrace __attribute((__section__(".noinstr.text"))) __no_kcsan
+       noinline notrace __attribute((__section__(".noinstr.text")))    \
+       __no_kcsan __no_sanitize_address __no_sanitize_undefined
 
 #endif /* __KERNEL__ */