gcc/libsanitizer
H.J. Lu c83b4b8242 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
2018-07-26 07:48:55 -07:00
..
asan libsanitizer: Mark REAL(swapcontext) with indirect_return attribute on x86 2018-07-26 07:48:55 -07:00
builtins
include
interception Enable building libsanitizer with Intel CET 2017-11-17 22:34:50 +01:00
libbacktrace Enable building libsanitizer with Intel CET 2017-11-17 22:34:50 +01:00
lsan Allow for lack of VM_MEMORY_OS_ALLOC_ONCE on Mac OS X (PR sanitizer/82824) 2018-01-13 21:01:27 +00:00
sanitizer_common libsanitizer: Mark REAL(swapcontext) with indirect_return attribute on x86 2018-07-26 07:48:55 -07:00
tsan Enable building libsanitizer with Intel CET 2017-11-17 22:34:50 +01:00
ubsan Revert 2018-07-05 11:47:05 +02:00
ChangeLog libsanitizer: Mark REAL(swapcontext) with indirect_return attribute on x86 2018-07-26 07:48:55 -07:00
HOWTO_MERGE
LICENSE.TXT
LOCAL_PATCHES
MERGE
Makefile.am Revert 2018-07-05 11:47:05 +02:00
Makefile.in Revert 2018-07-05 11:47:05 +02:00
README.gcc
acinclude.m4 Enable building libsanitizer with Intel CET 2017-11-17 22:34:50 +01:00
aclocal.m4
config.h.in re PR sanitizer/86090 ([ASAN] ASAN does not properly configure libbacktrace.) 2018-06-13 22:51:42 +03:00
configure re PR sanitizer/86090 ([ASAN] ASAN does not properly configure libbacktrace.) 2018-06-13 22:51:42 +03:00
configure.ac re PR sanitizer/86090 ([ASAN] ASAN does not properly configure libbacktrace.) 2018-06-13 22:51:42 +03:00
configure.tgt If someone has access to a 64-bit mips-linux system to test this (with the obvious edit), that'd be really nice. 2018-04-26 01:16:47 +00:00
libsanitizer.spec.in
libtool-version
merge.sh

README.gcc

AddressSanitizer (http://code.google.com/p/address-sanitizer) and
ThreadSanitizer (http://code.google.com/p/thread-sanitizer/) are
projects initially developed by Google Inc.
Both tools consist of a compiler module and a run-time library.
The sources of the run-time library for these projects are hosted at
http://llvm.org/svn/llvm-project/compiler-rt in the following directories:
  include/sanitizer
  lib/sanitizer_common
  lib/interception
  lib/asan
  lib/tsan
  lib/lsan
  lib/ubsan

Trivial and urgent fixes (portability, build fixes, etc.) may go directly to the
GCC tree.  All non-trivial changes, functionality improvements, etc. should go
through the upstream tree first and then be merged back to the GCC tree.
The merges from upstream should be done with the aid of the merge.sh script;
it will also update the file MERGE to contain the upstream revision
we merged with.