This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Add Scudo as a possible -fsanitize= option
ClosedPublic

Authored by cryptoad on Oct 26 2017, 8:52 AM.

Details

Summary

This change adds Scudo as a possible Sanitizer option via -fsanitize=.
This allows for easier static & shared linking of the Scudo library, it allows
us to enforce PIE (otherwise the security of the allocator is moot), and check
for incompatible Sanitizers combo.

In its current form, Scudo is not compatible with any other Sanitizer, but the
plan is to make it work in conjunction with UBsan (-fsanitize=scudo,undefined),
which will require additional work outside of the scope of this change.

Event Timeline

cryptoad created this revision.Oct 26 2017, 8:52 AM
alekseyshl added inline comments.Oct 26 2017, 11:22 AM
lib/Driver/SanitizerArgs.cpp
376

It's a pair of SanitizerMasks, why not add std::make_pair(Scudo, Address | Leak | Thread | Memory | KernelAddress | Undefined)?

lib/Driver/ToolChains/CommonArgs.cpp
575–577

Minor: add an empty line here or remove the one you added before needsUbsanRt.

test/Driver/fsanitize.c
630

Why checking just these two combinations?

cryptoad added inline comments.Oct 26 2017, 11:35 AM
lib/Driver/SanitizerArgs.cpp
376

I'll see if it can be done, I went the way the previous checks were previously made.

lib/Driver/ToolChains/CommonArgs.cpp
575–577

Just to make sure: there are currently no empty line before needsUbsanRt (it was removed for consistency).
So currently there is 0 empty line: would you rather 1 on each side of needsUbsanRt?

test/Driver/fsanitize.c
630

I figured the ASan one was to verify one incompatibility case, and the undefined one is here as well because it will end up being allowed when I figure out how to make the 2 cooperate nicely. I'll add them all.

alekseyshl added inline comments.Oct 26 2017, 1:08 PM
lib/Driver/ToolChains/CommonArgs.cpp
575–577

Indeed! Please ignore.

cryptoad updated this revision to Diff 120480.Oct 26 2017, 1:27 PM
cryptoad marked 7 inline comments as done.

Compacting IncompatibleGroups by creating a mask of incompatible sanitizers
instead to make pairs of single sanitizer. Tests appear to pass without issue.

Adding additional incompatible sanitizer tests for Scudo.

alekseyshl accepted this revision.Oct 27 2017, 10:50 AM
This revision is now accepted and ready to land.Oct 27 2017, 10:50 AM
cryptoad requested review of this revision.Oct 30 2017, 12:18 PM
cryptoad edited edge metadata.

Reopening this.
I am going to change the Scudo make to split the C vs CXX static runtimes. This will require changes here as well.
This patch will be updated soon.

cryptoad updated this revision to Diff 121039.Oct 31 2017, 1:10 PM

Make Scudo compatible with UBSan (see D39461 for the compiler-rt related
changes).

alekseyshl accepted this revision.Nov 1 2017, 11:16 AM
This revision is now accepted and ready to land.Nov 1 2017, 11:16 AM
eugenis accepted this revision.Nov 1 2017, 2:50 PM
cryptoad updated this revision to Diff 121499.Nov 3 2017, 10:04 AM

Rebasing.

cryptoad closed this revision.Nov 3 2017, 10:04 AM