This is an archive of the discontinued LLVM Phabricator instance.

[dfsan] Clean TLS after signal callbacks
ClosedPublic

Authored by stephan.yichao.zhao on Feb 2 2021, 2:37 PM.

Details

Diff Detail

Event Timeline

stephan.yichao.zhao requested review of this revision.Feb 2 2021, 2:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2021, 2:37 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
morehouse added inline comments.Feb 2 2021, 4:46 PM
compiler-rt/lib/dfsan/dfsan_custom.cpp
956

Side question: how does this trampoline get inserted?

962–975

Can remove some casting like this.

971

Don't we need to check that ret == SignalHandler before changing it?

compiler-rt/test/dfsan/custom.cpp
866

Shouldn't this return SIG_DFL?

stephan.yichao.zhao marked 4 inline comments as done.

updated

compiler-rt/lib/dfsan/dfsan_custom.cpp
956

It is by this.

For normal function pointer arguments, we can use it like

dfsan_label ret_l;
handler_trampoline(handler, signo, 0, &ret_l);

pthread_create does so.

In this case, we have SignalHandler shared with sigaction to do the similar work. So I ignored it.
The reason that sigaction must define its own SignalHandler and SigAction is because our code knows only how to create trampoline to top-level function pointers.

971

Yes. Thank you. Also changed test cases.

compiler-rt/test/dfsan/custom.cpp
866

updated. will be adding similar test cases for test_sigaction later.

morehouse accepted this revision.Feb 3 2021, 7:57 AM
morehouse added inline comments.
compiler-rt/lib/dfsan/dfsan_custom.cpp
970

Nit: The != SIG_ERR check is now unnecessary.

This revision is now accepted and ready to land.Feb 3 2021, 7:57 AM

addressed comments

stephan.yichao.zhao marked an inline comment as done.Feb 3 2021, 9:16 AM
This revision was landed with ongoing or failed builds.Feb 3 2021, 9:22 AM
This revision was automatically updated to reflect the committed changes.