[ASan] Initial support for Kernel AddressSanitizer
This patch adds initial support for the -fsanitize=kernel-address flag to Clang.
Right now it's quite restricted: only out-of-line instrumentation is supported, globals are not instrumented, some GCC kasan flags are not supported.
Using this patch I am able to build and boot the KASan tree with LLVMLinux patches from github.com/ramosian-glider/kasan/tree/kasan_llvmlinux.
To disable KASan instrumentation for a certain function attribute((no_sanitize("kernel-address"))) can be used.
llvm-svn: 240131
This commit is contained in:
@@ -615,7 +615,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD,
|
||||
}
|
||||
|
||||
// Apply sanitizer attributes to the function.
|
||||
if (SanOpts.has(SanitizerKind::Address))
|
||||
if (SanOpts.hasOneOf(SanitizerKind::Address | SanitizerKind::KernelAddress))
|
||||
Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
|
||||
if (SanOpts.has(SanitizerKind::Thread))
|
||||
Fn->addFnAttr(llvm::Attribute::SanitizeThread);
|
||||
|
||||
Reference in New Issue
Block a user