[PATCH] [ASan] Initial support for Kernel AddressSanitizer

Alexander Potapenko glider at google.com
Tue Jun 16 07:11:37 PDT 2015


I've added the tests for -fsanitize=kernel-address

- check that it instruments memory accesses
- check that the sanitize_address attributes are emitted

Regarding the offset/scale, these aren't emitted now, as I've only implemented the out-of-line instrumentation.
Regarding the missing module ctors, these will be added once we've globals instrumentation - not sure we need to test that they're absent now.

I've also added the -enable-kasan flag, but the existing tests do not use it yet.


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

================
Comment at: tools/clang/include/clang/Basic/Sanitizers.h:56
@@ +55,3 @@
+  /// \brief Check if either ASan or KASan is enabled.
+  bool hasAsanOrKasan() const;
+
----------------
samsonov wrote:
> 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...
This is basically the `has()` method without the `llvm::countPopulation(K) == 1` check.
Why not use a mask instead of an ArrayRef?

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

http://reviews.llvm.org/D10411

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






More information about the llvm-commits mailing list