This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Implement a __asan_default_options() equivalent for Scudo
ClosedPublic

Authored by cryptoad on Aug 1 2016, 9:16 AM.

Details

Summary

Currently, the Scudo Hardened Allocator only gets its flags via the SCUDO_OPTIONS environment variable.
With this patch, we offer the opportunity for programs to define their own options via scudo_default_options() which behaves like asan_default_options() (weak symbol).
A relevant test has been added as well, and the documentation updated accordingly.
I also used this patch as an opportunity to rename a few variables to comply with the LLVM naming scheme, and replaced a use of Report with dieWithMessage for consistency (and to avoid a callback).

Diff Detail

Event Timeline

cryptoad updated this revision to Diff 66331.Aug 1 2016, 9:16 AM
cryptoad retitled this revision from to [sanitizer] Implement a __asan_default_options() equivalent for Scudo.
cryptoad updated this object.
cryptoad added reviewers: kcc, llvm-commits.
kcc edited edge metadata.Aug 2 2016, 11:54 AM

Is your choice of the name (getScudoDefaultOptions, w/o "") deliberate?
With
you are guaranteed that no user code will have such a name since __ names are reserved for the implementation.
With getScudoDefaultOptions you don't have such guarantee.

Otherwise LG

In D23018#503660, @kcc wrote:

Is your choice of the name (getScudoDefaultOptions, w/o "") deliberate?
With
you are guaranteed that no user code will have such a name since __ names are reserved for the implementation.
With getScudoDefaultOptions you don't have such guarantee.

Otherwise LG

I couldn't find anything in the coding standards (http://llvm.org/docs/CodingStandards.html) that was covering this case, so I went with the default naming for a function.
If that's acceptable to prefix with __, then I am all for it!

kcc added a comment.Aug 2 2016, 2:25 PM

I think it *has* to be prefixed with __ to avoid clashing with user code (according to the C++ standard, afiact, user functions can not start with )
For consistency with asan's
asan_default_options, I would call it __scudo_default_options.

(We already broke the consistency a bit by using CamelCase in the names of options)

cryptoad updated this revision to Diff 66567.Aug 2 2016, 3:24 PM
cryptoad updated this object.
cryptoad edited edge metadata.

Diff updated with changes to the documentation. __scudo_default_options is now the name of the weak symbol used for options.
Additionally, using this as a vehicle to remove a use of Report in CheckFailed that was inconsistent with the rest, for the preferred dieWithMessage (this will be needed for the new Printf).

kcc accepted this revision.Aug 2 2016, 3:30 PM
kcc edited edge metadata.

LGTM, let me land it.

This revision is now accepted and ready to land.Aug 2 2016, 3:30 PM
kcc closed this revision.Aug 2 2016, 3:33 PM
eugenis added a subscriber: eugenis.Aug 2 2016, 4:24 PM

/code/llvm/projects/compiler-rt/lib/scudo/scudo_termination.cpp:40:1: error: function declared 'noreturn' should not return [-Werror,-Winvalid-noreturn]
}
^
1 error generated.

Please test with LLVM_ENABLE_WERROR.