LLVM
8.0.1
|
This file is a part of HWAddressSanitizer, an address sanity checker based on tagged addressing. More...
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Instrumentation.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include "llvm/Transforms/Utils/PromoteMemToReg.h"
#include <sstream>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "hwasan" |
Functions | |
INITIALIZE_PASS_BEGIN (HWAddressSanitizer, "hwasan", "HWAddressSanitizer: detect memory bugs using tagged addressing.", false, false) INITIALIZE_PASS_END(HWAddressSanitizer | |
static unsigned | getPointerOperandIndex (Instruction *I) |
static size_t | TypeSizeToSizeIndex (uint32_t TypeSize) |
static uint64_t | getAllocaSizeInBytes (const AllocaInst &AI) |
static unsigned | RetagMask (unsigned AllocaNo) |
Variables | |
static const char *const | kHwasanModuleCtorName = "hwasan.module_ctor" |
static const char *const | kHwasanInitName = "__hwasan_init" |
static const char *const | kHwasanShadowMemoryDynamicAddress |
static const size_t | kNumberOfAccessSizes = 5 |
static const size_t | kDefaultShadowScale = 4 |
static const uint64_t | kDynamicShadowSentinel |
static const unsigned | kPointerTagShift = 56 |
static const unsigned | kShadowBaseAlignment = 32 |
static cl::opt< std::string > | ClMemoryAccessCallbackPrefix ("hwasan-memory-access-callback-prefix", cl::desc("Prefix for memory access callbacks"), cl::Hidden, cl::init("__hwasan_")) |
static cl::opt< bool > | ClInstrumentWithCalls ("hwasan-instrument-with-calls", cl::desc("instrument reads and writes with callbacks"), cl::Hidden, cl::init(false)) |
static cl::opt< bool > | ClInstrumentReads ("hwasan-instrument-reads", cl::desc("instrument read instructions"), cl::Hidden, cl::init(true)) |
static cl::opt< bool > | ClInstrumentWrites ("hwasan-instrument-writes", cl::desc("instrument write instructions"), cl::Hidden, cl::init(true)) |
static cl::opt< bool > | ClInstrumentAtomics ("hwasan-instrument-atomics", cl::desc("instrument atomic instructions (rmw, cmpxchg)"), cl::Hidden, cl::init(true)) |
static cl::opt< bool > | ClRecover ("hwasan-recover", cl::desc("Enable recovery mode (continue-after-error)."), cl::Hidden, cl::init(false)) |
static cl::opt< bool > | ClInstrumentStack ("hwasan-instrument-stack", cl::desc("instrument stack (allocas)"), cl::Hidden, cl::init(true)) |
static cl::opt< bool > | ClUARRetagToZero ("hwasan-uar-retag-to-zero", cl::desc("Clear alloca tags before returning from the function to allow " "non-instrumented and instrumented function calls mix. When set " "to false, allocas are retagged before returning from the " "function to detect use after return."), cl::Hidden, cl::init(true)) |
static cl::opt< bool > | ClGenerateTagsWithCalls ("hwasan-generate-tags-with-calls", cl::desc("generate new tags with runtime library calls"), cl::Hidden, cl::init(false)) |
static cl::opt< int > | ClMatchAllTag ("hwasan-match-all-tag", cl::desc("don't report bad accesses via pointers with this tag"), cl::Hidden, cl::init(-1)) |
static cl::opt< bool > | ClEnableKhwasan ("hwasan-kernel", cl::desc("Enable KernelHWAddressSanitizer instrumentation"), cl::Hidden, cl::init(false)) |
static cl::opt< unsigned long long > | ClMappingOffset ("hwasan-mapping-offset", cl::desc("HWASan shadow mapping offset [EXPERIMENTAL]"), cl::Hidden, cl::init(0)) |
static cl::opt< bool > | ClWithIfunc ("hwasan-with-ifunc", cl::desc("Access dynamic shadow through an ifunc global on " "platforms that support this"), cl::Hidden, cl::init(false)) |
static cl::opt< bool > | ClWithTls ("hwasan-with-tls", cl::desc("Access dynamic shadow through an thread-local pointer on " "platforms that support this"), cl::Hidden, cl::init(true)) |
static cl::opt< bool > | ClRecordStackHistory ("hwasan-record-stack-history", cl::desc("Record stack frames with tagged allocations " "in a thread-local ring buffer"), cl::Hidden, cl::init(true)) |
static cl::opt< bool > | ClCreateFrameDescriptions ("hwasan-create-frame-descriptions", cl::desc("create static frame descriptions"), cl::Hidden, cl::init(true)) |
static cl::opt< bool > | ClInstrumentMemIntrinsics ("hwasan-instrument-mem-intrinsics", cl::desc("instrument memory intrinsics"), cl::Hidden, cl::init(true)) |
hwasan | |
HWAddressSanitizer | __pad0__ |
HWAddressSanitizer | false |
This file is a part of HWAddressSanitizer, an address sanity checker based on tagged addressing.
Definition in file HWAddressSanitizer.cpp.
#define DEBUG_TYPE "hwasan" |
Definition at line 51 of file HWAddressSanitizer.cpp.
|
static |
Definition at line 634 of file HWAddressSanitizer.cpp.
References assert(), ClInstrumentWithCalls, llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateIntToPtr(), llvm::IRBuilderBase::CreateMemSet(), llvm::IRBuilder< T, Inserter >::CreatePointerCast(), llvm::IRBuilder< T, Inserter >::CreateTrunc(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::AllocaInst::getAllocatedType(), llvm::AllocaInst::getArraySize(), llvm::Module::getDataLayout(), llvm::IRBuilderBase::getInt8Ty(), llvm::Instruction::getModule(), llvm::AllocaInst::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::ConstantInt::getZExtValue(), llvm::AllocaInst::isArrayAllocation(), Size, and llvm::Tag.
Referenced by GlobalWasGeneratedByCompiler(), RedzoneSizeForScale(), and RetagMask().
|
static |
Definition at line 479 of file HWAddressSanitizer.cpp.
References llvm::report_fatal_error(), and SI.
Referenced by TypeSizeToSizeIndex().
INITIALIZE_PASS_BEGIN | ( | HWAddressSanitizer | , |
"hwasan" | , | ||
"HWAddressSanitizer: detect memory bugs using tagged addressing." | , | ||
false | , | ||
false | |||
) |
Definition at line 672 of file HWAddressSanitizer.cpp.
References llvm::PHINode::addIncoming(), llvm::appendToCompilerUsed(), assert(), ClCreateFrameDescriptions, ClEnableKhwasan, ClGenerateTagsWithCalls, ClInstrumentStack, ClInstrumentWithCalls, ClMappingOffset, ClRecordStackHistory, ClUARRetagToZero, ClWithIfunc, ClWithTls, llvm::IRBuilder< T, Inserter >::CreateAdd(), llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateAShr(), llvm::MDBuilder::createBranchWeights(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateConstGEP1_32(), llvm::IRBuilder< T, Inserter >::CreateICmpEQ(), llvm::IRBuilder< T, Inserter >::CreateIntToPtr(), llvm::IRBuilder< T, Inserter >::CreateLoad(), llvm::IRBuilder< T, Inserter >::CreateLShr(), llvm::IRBuilder< T, Inserter >::CreateOr(), llvm::IRBuilder< T, Inserter >::CreatePHI(), llvm::IRBuilder< T, Inserter >::CreatePointerCast(), llvm::createPrivateGlobalForString(), llvm::IRBuilder< T, Inserter >::CreatePtrToInt(), llvm::IRBuilder< T, Inserter >::CreateShl(), llvm::IRBuilder< T, Inserter >::CreateStore(), llvm::IRBuilder< T, Inserter >::CreateXor(), llvm::IRBuilder< T, Inserter >::CreateZExt(), llvm::dbgs(), llvm::SmallVectorBase::empty(), F(), llvm::Intrinsic::frameaddress, llvm::ConstantInt::get(), llvm::StructType::get(), llvm::ConstantStruct::get(), llvm::AllocaInst::getAlignment(), getAllocaSizeInBytes(), llvm::AllocaInst::getAllocatedType(), llvm::Intrinsic::getDeclaration(), llvm::Function::getFnAttribute(), llvm::IRBuilderBase::GetInsertBlock(), llvm::IRBuilderBase::getInt32Ty(), llvm::Value::getName(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::Constant::getNullValue(), llvm::GetOrCreateFunctionComdat(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::Type::getPointerTo(), llvm::AllocaInst::getType(), llvm::Value::getType(), llvm::GlobalValue::getType(), llvm::Use::getUser(), llvm::Attribute::getValueAsString(), llvm::Function::hasFnAttribute(), llvm::Value::hasName(), llvm::cl::init(), llvm::isAllocaPromotable(), llvm::Type::isSized(), llvm::AllocaInst::isStaticAlloca(), llvm::AllocaInst::isSwiftError(), llvm::AllocaInst::isUsedWithInAlloca(), llvm::itostr(), kDefaultShadowScale, kDynamicShadowSentinel, kPointerTagShift, LLVM_DEBUG, N, Name, llvm::GlobalValue::PrivateLinkage, llvm::SmallVectorTemplateBase< T >::push_back(), runOnFunction(), llvm::Attribute::SanitizeHWAddress, llvm::Use::set(), llvm::AllocaInst::setAlignment(), llvm::IRBuilderBase::SetInsertPoint(), llvm::Value::setName(), llvm::SmallVectorBase::size(), llvm::SplitBlockAndInsertIfThen(), llvm::StringRef::str(), llvm::Tag, llvm::Intrinsic::thread_pointer, llvm::Value::use_begin(), and llvm::Value::use_end().
|
static |
Definition at line 492 of file HWAddressSanitizer.cpp.
References llvm::Triple::aarch64, llvm::Triple::aarch64_be, llvm::HexStyle::Asm, assert(), ClInstrumentMemIntrinsics, ClInstrumentWithCalls, ClMatchAllTag, llvm::countTrailingZeros(), llvm::IRBuilder< T, Inserter >::CreateAdd(), llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::MDBuilder::createBranchWeights(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateICmpNE(), llvm::IRBuilder< T, Inserter >::CreateIntCast(), llvm::IRBuilder< T, Inserter >::CreateIntToPtr(), llvm::IRBuilder< T, Inserter >::CreateLoad(), llvm::IRBuilder< T, Inserter >::CreateLShr(), llvm::IRBuilder< T, Inserter >::CreatePointerCast(), llvm::IRBuilder< T, Inserter >::CreateTrunc(), llvm::dbgs(), llvm::Instruction::eraseFromParent(), llvm::InlineAsm::get(), llvm::ConstantInt::get(), llvm::FunctionType::get(), llvm::IRBuilderBase::getInt32Ty(), llvm::IRBuilderBase::getInt8PtrTy(), llvm::IRBuilderBase::getInt8Ty(), llvm::User::getOperand(), getPointerOperandIndex(), llvm::Value::getType(), llvm::IRBuilderBase::getVoidTy(), llvm::isPowerOf2_64(), llvm::itostr(), kNumberOfAccessSizes, LLVM_DEBUG, MI, llvm::report_fatal_error(), llvm::IRBuilderBase::SetInsertPoint(), llvm::User::setOperand(), llvm::SplitBlockAndInsertIfThen(), and llvm::Triple::x86_64.
HWAddressSanitizer __pad0__ |
Definition at line 284 of file HWAddressSanitizer.cpp.
|
static |
Referenced by RetagMask().
|
static |
Referenced by RetagMask().
|
static |
Referenced by RetagMask().
|
static |
Referenced by llvm::createHWAddressSanitizerPass().
|
static |
Referenced by TypeSizeToSizeIndex().
|
static |
Referenced by llvm::createHWAddressSanitizerPass().
|
static |
Referenced by RetagMask().
|
static |
Referenced by getAllocaSizeInBytes(), RetagMask(), and TypeSizeToSizeIndex().
|
static |
Referenced by llvm::createHWAddressSanitizerPass().
|
static |
Referenced by RetagMask().
|
static |
Referenced by TypeSizeToSizeIndex().
|
static |
Referenced by llvm::createHWAddressSanitizerPass().
|
static |
Referenced by RetagMask().
|
static |
|
static |
Referenced by RetagMask().
|
static |
Referenced by RetagMask().
|
static |
Referenced by RetagMask().
HWAddressSanitizer false |
Definition at line 284 of file HWAddressSanitizer.cpp.
hwasan |
Definition at line 284 of file HWAddressSanitizer.cpp.
|
static |
Definition at line 62 of file HWAddressSanitizer.cpp.
Referenced by RetagMask().
|
static |
Definition at line 63 of file HWAddressSanitizer.cpp.
Referenced by llvm::createHWAddressSanitizerPass(), and RetagMask().
Definition at line 54 of file HWAddressSanitizer.cpp.
Definition at line 53 of file HWAddressSanitizer.cpp.
Definition at line 56 of file HWAddressSanitizer.cpp.
|
static |
Definition at line 60 of file HWAddressSanitizer.cpp.
Referenced by llvm::createHWAddressSanitizerPass(), and TypeSizeToSizeIndex().
Definition at line 65 of file HWAddressSanitizer.cpp.
Referenced by RetagMask().
Definition at line 67 of file HWAddressSanitizer.cpp.