[PATCH] [ASan] Initial support for Kernel AddressSanitizer
Alexander Potapenko
glider at google.com
Thu Jun 18 05:47:17 PDT 2015
================
Comment at: lib/Transforms/Instrumentation/AddressSanitizer.cpp:1366
@@ +1365,3 @@
+ Function *CtorFunc = M.getFunction(kAsanModuleCtorName);
+ if (!CtorFunc && CompileKernel) {
+ CtorFunc = Function::Create(
----------------
samsonov wrote:
> Wait, this is dead code, right? `CompileKernel` is known to be false here, as you've checked it in the outer `if`.
Removed the dead code for now. This block will be added back once we enable globals instrumentation.
================
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))
----------------
samsonov wrote:
> `hasOneOf`
Done
================
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))
----------------
samsonov wrote:
> (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?
Yes, I'm about to add globals support soon, it's just not working properly yet.
================
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
----------------
samsonov wrote:
> Please specify triple (or merge this into `address-safety-attr.cpp` somehow)
Done.
================
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
----------------
samsonov wrote:
> `Function Attrs: nounwind sanitize_address`
> would match this CHECK-NOASAN line
Added a $ after "nounwind"
http://reviews.llvm.org/D10411
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list