[llvm] r212505 - [ASan] Completely remove sanitizer blacklist file from instrumentation pass.

Alexey Samsonov vonosmas at gmail.com
Tue Jul 8 09:56:54 PDT 2014


SpecialCaseList is still used in DFSan instrumentation pass. However, I
definitely would work on turning blacklist into a Clang class - we should
blacklist items based on the source information instead of using
llvm::Function name or llvm::Module module identifier. More changes to go.


On Tue, Jul 8, 2014 at 1:19 AM, Benjamin Kramer <benny.kra at gmail.com> wrote:

> On Tue, Jul 8, 2014 at 2:50 AM, Alexey Samsonov <vonosmas at gmail.com>
> wrote:
> > Author: samsonov
> > Date: Mon Jul  7 19:50:49 2014
> > New Revision: 212505
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=212505&view=rev
> > Log:
> > [ASan] Completely remove sanitizer blacklist file from instrumentation
> pass.
>
> Can SpecialCaseList now move to Clang? It's a bit strange to have a
> dependency from clangDriver to LLVMTransformUtils.
>
> - Ben
>
> >
> > All blacklisting logic is now moved to the frontend (Clang).
> > If a function (or source file it is in) is blacklisted, it doesn't
> > get sanitize_address attribute and is therefore not instrumented.
> > If a global variable (or source file it is in) is blacklisted, it is
> > reported to be blacklisted by the entry in llvm.asan.globals metadata,
> > and is not modified by the instrumentation.
> >
> > The latter may lead to certain false positives - not all the globals
> > created by Clang are described in llvm.asan.globals metadata (e.g,
> > RTTI descriptors are not), so we may start reporting errors on them
> > even if "module" they appear in is blacklisted. We assume it's fine
> > to take such risk:
> >   1) errors on these globals are rare and usually indicate wild memory
> access
> >   2) we can lazily add descriptors for these globals into
> llvm.asan.globals
> >      lazily.
> >
> >
> > Modified:
> >     llvm/trunk/include/llvm/Transforms/Instrumentation.h
> >     llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
> >
> > Modified: llvm/trunk/include/llvm/Transforms/Instrumentation.h
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Instrumentation.h?rev=212505&r1=212504&r2=212505&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/include/llvm/Transforms/Instrumentation.h (original)
> > +++ llvm/trunk/include/llvm/Transforms/Instrumentation.h Mon Jul  7
> 19:50:49 2014
> > @@ -65,8 +65,7 @@ ModulePass *createGCOVProfilerPass(const
> >
> >  // Insert AddressSanitizer (address sanity checking) instrumentation
> >  FunctionPass *createAddressSanitizerFunctionPass();
> > -ModulePass *
> > -createAddressSanitizerModulePass(StringRef BlacklistFile = StringRef());
> > +ModulePass *createAddressSanitizerModulePass();
> >
> >  // Insert MemorySanitizer instrumentation (detection of uninitialized
> reads)
> >  FunctionPass *createMemorySanitizerPass(int TrackOrigins = 0);
> >
> > Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=212505&r1=212504&r2=212505&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
> (original)
> > +++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Mon
> Jul  7 19:50:49 2014
> > @@ -45,7 +45,6 @@
> >  #include "llvm/Transforms/Utils/Cloning.h"
> >  #include "llvm/Transforms/Utils/Local.h"
> >  #include "llvm/Transforms/Utils/ModuleUtils.h"
> > -#include "llvm/Transforms/Utils/SpecialCaseList.h"
> >  #include <algorithm>
> >  #include <string>
> >  #include <system_error>
> > @@ -149,9 +148,6 @@ static cl::opt<bool> ClInvalidPointerPai
> >  static cl::opt<unsigned> ClRealignStack("asan-realign-stack",
> >         cl::desc("Realign stack to the value of this flag (power of
> two)"),
> >         cl::Hidden, cl::init(32));
> > -static cl::opt<std::string> ClBlacklistFile("asan-blacklist",
> > -       cl::desc("File containing the list of objects to ignore "
> > -                "during instrumentation"), cl::Hidden);
> >  static cl::opt<int> ClInstrumentationWithCallsThreshold(
> >      "asan-instrumentation-with-call-threshold",
> >         cl::desc("If the function being instrumented contains more than "
> > @@ -418,9 +414,7 @@ struct AddressSanitizer : public Functio
> >
> >  class AddressSanitizerModule : public ModulePass {
> >   public:
> > -  AddressSanitizerModule(StringRef BlacklistFile = StringRef())
> > -      : ModulePass(ID), BlacklistFile(BlacklistFile.empty() ?
> ClBlacklistFile
> > -                                                            :
> BlacklistFile) {}
> > +  AddressSanitizerModule() : ModulePass(ID) {}
> >    bool runOnModule(Module &M) override;
> >    static char ID;  // Pass identification, replacement for typeid
> >    const char *getPassName() const override {
> > @@ -438,9 +432,6 @@ class AddressSanitizerModule : public Mo
> >      return RedzoneSizeForScale(Mapping.Scale);
> >    }
> >
> > -  SmallString<64> BlacklistFile;
> > -
> > -  std::unique_ptr<SpecialCaseList> BL;
> >    GlobalsMetadata GlobalsMD;
> >    Type *IntptrTy;
> >    LLVMContext *C;
> > @@ -601,8 +592,8 @@ char AddressSanitizerModule::ID = 0;
> >  INITIALIZE_PASS(AddressSanitizerModule, "asan-module",
> >      "AddressSanitizer: detects use-after-free and out-of-bounds bugs."
> >      "ModulePass", false, false)
> > -ModulePass *llvm::createAddressSanitizerModulePass(StringRef
> BlacklistFile) {
> > -  return new AddressSanitizerModule(BlacklistFile);
> > +ModulePass *llvm::createAddressSanitizerModulePass() {
> > +  return new AddressSanitizerModule();
> >  }
> >
> >  static size_t TypeSizeToSizeIndex(uint32_t TypeSize) {
> > @@ -926,9 +917,6 @@ bool AddressSanitizerModule::ShouldInstr
> >    Type *Ty = cast<PointerType>(G->getType())->getElementType();
> >    DEBUG(dbgs() << "GLOBAL: " << *G << "\n");
> >
> > -  // FIXME: Don't use the blacklist here, all the data should be
> collected
> > -  // by the frontend and passed in globals metadata.
> > -  if (BL->isIn(*G)) return false;
> >    if (GlobalsMD.isBlacklisted(G)) return false;
> >    if (GlobalsMD.isSourceLocationGlobal(G)) return false;
> >    if (!Ty->isSized()) return false;
> > @@ -1163,7 +1151,6 @@ bool AddressSanitizerModule::runOnModule
> >    if (!DLP)
> >      return false;
> >    DL = &DLP->getDataLayout();
> > -  BL.reset(SpecialCaseList::createOrDie(BlacklistFile));
> >    C = &(M.getContext());
> >    int LongSize = DL->getPointerSizeInBits();
> >    IntptrTy = Type::getIntNTy(*C, LongSize);
> > @@ -1183,7 +1170,8 @@ bool AddressSanitizerModule::runOnModule
> >      Changed = true;
> >    }
> >
> > -  if (ClGlobals && !BL->isIn(M)) Changed |= InstrumentGlobals(IRB, M);
> > +  if (ClGlobals)
> > +    Changed |= InstrumentGlobals(IRB, M);
> >
> >    return Changed;
> >  }
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



-- 
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140708/f5ec1eb3/attachment.html>


More information about the llvm-commits mailing list