Cherry-pick compiler-rt revision 337603:
When shadow stack from Intel CET is enabled, the first instruction of all
indirect branch targets must be a special instruction, ENDBR.
lib/asan/asan_interceptors.cc has
...
int res = REAL(swapcontext)(oucp, ucp);
...
REAL(swapcontext) is a function pointer to swapcontext in libc. Since
swapcontext may return via indirect branch on x86 when shadow stack is
enabled, as in this case,
int res = REAL(swapcontext)(oucp, ucp);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This function may be
returned via an indirect branch.
Here compiler must insert ENDBR after call, like
call *bar(%rip)
endbr64
I opened an LLVM bug:
https://bugs.llvm.org/show_bug.cgi?id=38207
to add the indirect_return attribute so that it can be used to inform
compiler to insert ENDBR after REAL(swapcontext) call. We mark
REAL(swapcontext) with the indirect_return attribute if it is available.
This fixed:
https://bugs.llvm.org/show_bug.cgi?id=38249
Reviewed By: eugenis
Differential Revision: https://reviews.llvm.org/D49608
PR target/86560
* asan/asan_interceptors.cc (swapcontext) Cherry-pick
compiler-rt revision 337603.
* sanitizer_common/sanitizer_internal_defs.h (__has_attribute):
Likewise.
From-SVN: r263009
| Name |
Last commit
|
Last update |
|---|---|---|
| .. | ||
| asan | Loading commit data... | |
| builtins | Loading commit data... | |
| include | Loading commit data... | |
| interception | Loading commit data... | |
| libbacktrace | Loading commit data... | |
| lsan | Loading commit data... | |
| sanitizer_common | Loading commit data... | |
| tsan | Loading commit data... | |
| ubsan | Loading commit data... | |
| ChangeLog | Loading commit data... | |
| HOWTO_MERGE | Loading commit data... | |
| LICENSE.TXT | Loading commit data... | |
| LOCAL_PATCHES | Loading commit data... | |
| MERGE | Loading commit data... | |
| Makefile.am | Loading commit data... | |
| Makefile.in | Loading commit data... | |
| README.gcc | Loading commit data... | |
| acinclude.m4 | Loading commit data... | |
| aclocal.m4 | Loading commit data... | |
| config.h.in | Loading commit data... | |
| configure | Loading commit data... | |
| configure.ac | Loading commit data... | |
| configure.tgt | Loading commit data... | |
| libsanitizer.spec.in | Loading commit data... | |
| libtool-version | Loading commit data... | |
| merge.sh | Loading commit data... |