llvm-project/compiler-rt/lib
H.J. Lu 0cb55919ec Mark REAL(swapcontext) with indirect_return attribute on x86
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

llvm-svn: 337603
2018-07-20 19:24:11 +00:00
..
BlocksRuntime [compiler-rt] Test commit: remove some trailing white spaces. 2017-08-25 19:36:30 +00:00
asan Mark REAL(swapcontext) with indirect_return attribute on x86 2018-07-20 19:24:11 +00:00
builtins [builtins] Implement the __chkstk function for ARM for MinGW 2018-07-17 19:14:47 +00:00
cfi Fix warnings in a static assert added to CFI. 2018-07-16 15:01:26 +00:00
dfsan sanitizers: consistently check result of MmapFixedNoReserve 2018-07-20 08:33:41 +00:00
esan esan: fix shadow setup 2018-07-20 13:40:08 +00:00
fuzzer [libFuzzer] when -print_coverage=1 is given, print more stats (the number of seeds that hit every given function) 2018-07-19 22:00:48 +00:00
hwasan sanitizers: consistently check result of MmapFixedNoReserve 2018-07-20 08:33:41 +00:00
interception [CMake] Add compiler-rt header files to the list of sources for targets 2018-07-10 13:00:17 +00:00
lsan [CMake] Add compiler-rt header files to the list of sources for targets 2018-07-10 13:00:17 +00:00
msan sanitizers: consistently check result of MmapFixedNoReserve 2018-07-20 08:33:41 +00:00
profile [profile] Add interface to get profile filename 2018-07-19 19:03:50 +00:00
safestack Fix for Darwin buildbot failure due to r337037 2018-07-13 20:56:48 +00:00
sanitizer_common Mark REAL(swapcontext) with indirect_return attribute on x86 2018-07-20 19:24:11 +00:00
scudo [scudo] Simplify internal names (NFC) 2018-07-20 15:07:17 +00:00
stats [CMake] Add compiler-rt header files to the list of sources for targets 2018-07-10 13:00:17 +00:00
tsan sanitizers: consistently check result of MmapFixedNoReserve 2018-07-20 08:33:41 +00:00
ubsan [UBSan] Followup for silence_unsigned_overflow flag to handle negate overflows. 2018-07-13 22:49:06 +00:00
ubsan_minimal [CMake] Build shared version of runtimes for Fuchsia 2018-05-09 21:24:06 +00:00
xray [Xray] fix c99 warning build about flexible array semantics 2018-07-20 09:22:22 +00:00
CMakeLists.txt [cmake] Add a separate CMake var to control profile runtime 2017-10-02 05:03:55 +00:00