[PATCH] [ASan] Initial support for Kernel AddressSanitizer

Alexey Samsonov vonosmas at gmail.com
Wed Jun 17 12:27:35 PDT 2015


================
Comment at: lib/Transforms/Instrumentation/AddressSanitizer.cpp:1366
@@ +1365,3 @@
+    Function *CtorFunc = M.getFunction(kAsanModuleCtorName);
+    if (!CtorFunc && CompileKernel) {
+        CtorFunc = Function::Create(
----------------
Wait, this is dead code, right? `CompileKernel` is known to be false here, as you've checked it in the outer `if`.

================
Comment at: tools/clang/lib/CodeGen/CGDeclCXX.cpp:270
@@ -269,2 +269,3 @@
   if (!isInSanitizerBlacklist(Fn, Loc)) {
-    if (getLangOpts().Sanitize.has(SanitizerKind::Address))
+    if (getLangOpts().Sanitize.has(SanitizerKind::Address) ||
+        getLangOpts().Sanitize.has(SanitizerKind::KernelAddress))
----------------
`hasOneOf`

================
Comment at: tools/clang/lib/CodeGen/SanitizerMetadata.cpp:28
@@ -27,2 +27,3 @@
                                            bool IsBlacklisted) {
-  if (!CGM.getLangOpts().Sanitize.has(SanitizerKind::Address))
+  if (!CGM.getLangOpts().Sanitize.hasOneOf(SanitizerKind::Address |
+                                           SanitizerKind::KernelAddress))
----------------
(here and below)
I think you don't do anything with globals in KASan. Or you want to add it in the following changes soon?

================
Comment at: tools/clang/test/CodeGen/address-safety-attr-kasan.cpp:4
@@ +3,3 @@
+/// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NOASAN %s
+/// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-ASAN %s
+/// RUN: %clang_cc1 -fsanitize=kernel-address -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-KASAN %s
----------------
Please specify triple (or merge this into `address-safety-attr.cpp` somehow)

================
Comment at: tools/clang/test/CodeGen/address-safety-attr-kasan.cpp:10
@@ +9,3 @@
+}
+// CHECK-NOASAN: Function Attrs: nounwind
+// CHECK-ASAN: Function Attrs: nounwind sanitize_address
----------------
`Function Attrs: nounwind sanitize_address`
would match this CHECK-NOASAN line

http://reviews.llvm.org/D10411

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list