Skip to contentSkip to conversation

kasan: add compiler support for clang

PATCH New [email protected] 1 participant 1 message Feb 6, 2018 Clang/LLVM build support

lore
Share & tools
lore
#0 lore raw

PATCH 2/114 kasan: add compiler support for clang

From: Paul Lawrence <[email protected]>
Subject: kasan: add compiler support for clang

Patch series "kasan: support alloca, LLVM", v4.

This patch (of 5):

For now we can hard-code ASAN ABI level 5, since historical clang builds can't build the kernel anyway. We also need to emulate gcc's __SANITIZE_ADDRESS__ flag, or memset() calls won't be instrumented.

---

 include/linux/compiler-clang.h |    8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/compiler-clang.h renamed from include/linux/compiler-clang.h~kasan-add-compiler-support-for-clang +8 -0
diff -puN include/linux/compiler-clang.h~kasan-add-compiler-support-for-clang include/linux/compiler-clang.h
@@ -19,3 +19,11 @@
 
 #define randomized_struct_fields_start	struct {
 #define randomized_struct_fields_end	};
+
+/* all clang versions usable with the kernel support KASAN ABI version 5 */
+#define KASAN_ABI_VERSION 5
+
+/* emulate gcc's __SANITIZE_ADDRESS__ flag */
+#if __has_feature(address_sanitizer)
+#define __SANITIZE_ADDRESS__
+#endif

_