This is an archive of the discontinued LLVM Phabricator instance.

[RFC] Introduce support for multiple sanitizer blacklists (LLVM side).
Needs ReviewPublic

Authored by pcc on Jul 16 2014, 2:31 PM.

Details

Reviewers
samsonov
Summary

This adds support for multiple -fsanitize-blacklist flags, which cause
clang to load blacklists from each of the specified paths. This could be
useful for sanitizers such as DFSan where we may have multiple ABI lists,
each covering a specific library, which describes the ABI of that library.

This changes the semantics of the -fsanitize-blacklist flag, so I wanted to
make sure that we were comfortable with that. Now, the flag is additive, so a
-fsanitize-blacklist flag on the command line loads the specified blacklist
as well as the one in the resource directory. The -fno-sanitize-blacklist
flag works as before in that it prevents the blacklist in the resource
directory from being loaded, but it can also be used in combination with
-fsanitize-blacklist to load only user-specified blacklists.

Tests to come. I've removed the one test which fails as a result of the
changed semantics.

Diff Detail

Event Timeline

pcc updated this revision to Diff 11537.Jul 16 2014, 2:31 PM
pcc retitled this revision from to [RFC] Introduce support for multiple sanitizer blacklists (LLVM side)..
pcc updated this object.
pcc edited the test plan for this revision. (Show Details)
pcc added a reviewer: samsonov.
pcc added a subscriber: Unknown Object (MLST).
samsonov edited edge metadata.Jul 16 2014, 4:10 PM

I'm fine with general direction of this patch. Having multiple blacklists for different parts of code base looks like a legit use case.

I don't like proliferation of std::unique_ptr across interfaces, though. I would prefer to have them more lightweight. Can we add one more factory:

llvm::SpecialCaseList::createOrDie(const std::vector<std::string> &Paths);

In this case Clang's BackendUtil won't have to bother about creating SpecialCaseList - it will just pass CGOpts.SanitizerBlacklistFiles to the DFSan instrumentation pass.

lib/Support/SpecialCaseList.cpp
135–136

You're now using a vector of Regexps. Either use "|" (as done here) to merge them into a single Regexp, or use push_back everywhere.

pcc added a comment.Jul 16 2014, 8:23 PM

I don't like proliferation of std::unique_ptr across interfaces, though. I would prefer to have them more lightweight. Can we add one more factory:
llvm::SpecialCaseList::createOrDie(const std::vector<std::string> &Paths);
In this case Clang's BackendUtil won't have to bother about creating SpecialCaseList - it will just pass CGOpts.SanitizerBlacklistFiles to the DFSan instrumentation pass.

I would prefer not to. It seems to me that passing SpecialCaseLists around would give us a little more flexibility. For example, it would make it easier to accept ad-hoc entries on the command line, or do things like dynamically load ABI lists out of object files.

lib/Support/SpecialCaseList.cpp
135–136

Okay, I'll change this to use one regexp per entry. It doesn't seem like we were getting much benefit out of having a single regexp for all entries, given the poor performance I was seeing before.

pcc updated this revision to Diff 12251.Aug 6 2014, 2:15 PM
pcc edited edge metadata.

Add tests and address reviewer comments.