]> granicus.if.org Git - llvm/commit
hwasan: Untag unwound stack frames by wrapping personality functions.
authorPeter Collingbourne <peter@pcc.me.uk>
Fri, 23 Aug 2019 01:28:44 +0000 (01:28 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Fri, 23 Aug 2019 01:28:44 +0000 (01:28 +0000)
commit4c914636166a578c23ee3f8ce8cf16927bf47525
tree0751172a58987592097c3a1a23b77b5007211900
parentad3de21f68d4156ded6410cc93309614a35b572f
hwasan: Untag unwound stack frames by wrapping personality functions.

One problem with untagging memory in landing pads is that it only works
correctly if the function that catches the exception is instrumented.
If the function is uninstrumented, we have no opportunity to untag the
memory.

To address this, replace landing pad instrumentation with personality function
wrapping. Each function with an instrumented stack has its personality function
replaced with a wrapper provided by the runtime. Functions that did not have
a personality function to begin with also get wrappers if they may be unwound
past. As the unwinder calls personality functions during stack unwinding,
the original personality function is called and the function's stack frame is
untagged by the wrapper if the personality function instructs the unwinder
to keep unwinding. If unwinding stops at a landing pad, the function is
still responsible for untagging its stack frame if it resumes unwinding.

The old landing pad mechanism is preserved for compatibility with old runtimes.

Differential Revision: https://reviews.llvm.org/D66377

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369721 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
test/Instrumentation/HWAddressSanitizer/landingpad.ll
test/Instrumentation/HWAddressSanitizer/personality.ll [new file with mode: 0644]
utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn