[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:
@@ -1218,8 +1218,9 @@ bool CodeGenModule::isInSanitizerBlacklist(llvm::Function *Fn,
|
||||
bool CodeGenModule::isInSanitizerBlacklist(llvm::GlobalVariable *GV,
|
||||
SourceLocation Loc, QualType Ty,
|
||||
StringRef Category) const {
|
||||
// For now globals can be blacklisted only in ASan.
|
||||
if (!LangOpts.Sanitize.has(SanitizerKind::Address))
|
||||
// For now globals can be blacklisted only in ASan and KASan.
|
||||
if (!LangOpts.Sanitize.hasOneOf(
|
||||
SanitizerKind::Address | SanitizerKind::KernelAddress))
|
||||
return false;
|
||||
const auto &SanitizerBL = getContext().getSanitizerBlacklist();
|
||||
if (SanitizerBL.isBlacklistedGlobal(GV->getName(), Category))
|
||||
|
||||
Reference in New Issue
Block a user