This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer][esan] Add internal_sigaction_syscall
ClosedPublic

Authored by bruening on Jun 7 2016, 10:01 AM.

Details

Summary

Adds a version of sigaction that uses a raw system call, to avoid circular
dependencies and support calling sigaction prior to setting up
interceptors. The new sigaction relies on an assembly sigreturn routine
for its restorer, which is Linux x86_64-only for now.

Uses the new sigaction to initialize the working set tool's shadow fault
handler prior to libc interceptor being set up. This is required to
support instrumentation invoked during interceptor setup, which happens
with tcmalloc.

Diff Detail

Repository
rL LLVM

Event Timeline

bruening updated this revision to Diff 59903.Jun 7 2016, 10:01 AM
bruening retitled this revision from to [sanitizer][esan] Add internal_sigaction_syscall.
bruening updated this object.
bruening added a reviewer: aizatsky.
bruening added subscribers: llvm-commits, eugenis, kcc and 2 others.
aizatsky edited edge metadata.Jun 7 2016, 1:52 PM

Derek,

I feel that this definitely needs a test. Can you craft something up?

lib/sanitizer_common/sanitizer_linux.cc
683 ↗(On Diff #59903)

replace #ifs with ifs.

aizatsky requested changes to this revision.Jun 7 2016, 1:54 PM
aizatsky edited edge metadata.
This revision now requires changes to proceed.Jun 7 2016, 1:54 PM

I feel that this definitely needs a test. Can you craft something up?

Agreed, these changes to handle various native allocators are getting complex and messy. I do not want to pull tcmalloc into compiler-rt so I will see what I can do with a targeted test.

bruening updated this revision to Diff 60063.Jun 8 2016, 10:22 AM
bruening edited edge metadata.

Add a test that emulates an instrumented allocator.

bruening added inline comments.Jun 8 2016, 10:31 AM
lib/sanitizer_common/sanitizer_linux.cc
683 ↗(On Diff #60063)

Please elaborate: you're saying there are variables available to get the platform and that's preferable to the preprocessor defines? These preprocessor defines are what all the surrounding routines are using for this same type of code, so I'm not sure what other method you're suggesting.

aizatsky added inline comments.Jun 9 2016, 3:23 PM
lib/sanitizer_common/sanitizer_linux.cc
670 ↗(On Diff #60063)

Is the only difference between this and internal_sigaction_norestorer the handling of sa_restorer? Can you eliminate this duplication and reuse the code?

683 ↗(On Diff #60063)

Please disregard my comment. #ifs clearly guard fields access for undefined fields I guess.

bruening updated this revision to Diff 60358.Jun 10 2016, 8:52 AM
bruening edited edge metadata.

Shares code between the two sigaction routines.

bruening marked an inline comment as done.Jun 10 2016, 2:51 PM

PTAL

aizatsky accepted this revision.Jun 10 2016, 4:06 PM
aizatsky edited edge metadata.
This revision is now accepted and ready to land.Jun 10 2016, 4:06 PM
This revision was automatically updated to reflect the committed changes.