]> gcc.gnu.org Git - gcc.git/commit
libsanitizer: Mark REAL(swapcontext) with indirect_return attribute on x86
authorH.J. Lu <hongjiu.lu@intel.com>
Thu, 26 Jul 2018 14:48:55 +0000 (14:48 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Thu, 26 Jul 2018 14:48:55 +0000 (07:48 -0700)
commitc83b4b824214039fea696083e6a888aa7c9063ce
tree29ee396d3994048e553ca56048cded170b39d2b9
parent49ba258864794b0f65d0e59d31eea24e94952aea
libsanitizer: Mark REAL(swapcontext) with indirect_return attribute on x86

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
libsanitizer/ChangeLog
libsanitizer/asan/asan_interceptors.cc
libsanitizer/sanitizer_common/sanitizer_internal_defs.h
This page took 0.061469 seconds and 5 git commands to generate.