[PATCH] [ASan] Initial support for Kernel AddressSanitizer

Alexey Samsonov vonosmas at gmail.com
Mon Jun 15 13:35:00 PDT 2015


I think it's fine to add whatever commandline flags are needed for testing - they are not user-visible anyway, and we should have *some* means to test KASan instrumentation without a frontend.

Looks mostly good.


================
Comment at: lib/Transforms/Instrumentation/AddressSanitizer.cpp:1447
@@ +1446,3 @@
+  if (!CompileKernel)
+    appendToGlobalCtors(M, AsanCtorFunction, kAsanCtorAndDtorPriority);
+  Mapping = getShadowMapping(TargetTriple, LongSize, CompileKernel);
----------------
I would actually prefer a null initialization, as it's weird to create functions that would never be called in KASan mode.

================
Comment at: tools/clang/include/clang/Basic/Sanitizers.h:56
@@ +55,3 @@
+  /// \brief Check if either ASan or KASan is enabled.
+  bool hasAsanOrKasan() const;
+
----------------
Um, no, I mean to add `hasOneOf` method that would take ArrayRef of sanitizer kinds and return true iff at least one of them is enabled. Then you could call it as...

================
Comment at: tools/clang/lib/AST/Decl.cpp:3684
@@ -3683,3 +3683,3 @@
   ASTContext &Context = getASTContext();
-  if (!Context.getLangOpts().Sanitize.has(SanitizerKind::Address) ||
+  if (!(Context.getLangOpts().Sanitize.hasAsanOrKasan()) ||
       !Context.getLangOpts().SanitizeAddressFieldPadding)
----------------
  Context.getLangOpts().Sanitize.hasOneOf({SanitizerKind::Address, SanitizerKind::KernelAddress})

================
Comment at: tools/clang/lib/CodeGen/BackendUtil.cpp:204
@@ -203,3 +203,3 @@
                                       legacy::PassManagerBase &PM) {
   PM.add(createAddressSanitizerFunctionPass());
   PM.add(createAddressSanitizerModulePass());
----------------
Pass false here.

http://reviews.llvm.org/D10411

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






More information about the llvm-commits mailing list