gcc/libsanitizer/asan
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
..
Makefile.am
Makefile.in
asan_activation.cc
asan_activation.h
asan_activation_flags.inc
asan_allocator.cc
asan_allocator.h
asan_debugging.cc
asan_descriptions.cc
asan_descriptions.h
asan_errors.cc
asan_errors.h
asan_fake_stack.cc
asan_fake_stack.h
asan_flags.cc
asan_flags.h
asan_flags.inc
asan_fuchsia.cc
asan_globals.cc
asan_globals_win.cc
asan_init_version.h
asan_interceptors.cc libsanitizer: Mark REAL(swapcontext) with indirect_return attribute on x86 2018-07-26 07:48:55 -07:00
asan_interceptors.h
asan_interceptors_memintrinsics.cc
asan_interceptors_memintrinsics.h
asan_interface.inc
asan_interface_internal.h
asan_internal.h
asan_linux.cc
asan_lock.h
asan_mac.cc
asan_malloc_linux.cc
asan_malloc_mac.cc
asan_malloc_win.cc
asan_mapping.h
asan_memory_profile.cc
asan_new_delete.cc
asan_poisoning.cc
asan_poisoning.h
asan_posix.cc
asan_preinit.cc
asan_report.cc
asan_report.h
asan_rtl.cc
asan_scariness_score.h
asan_shadow_setup.cc
asan_stack.cc
asan_stack.h
asan_stats.cc
asan_stats.h
asan_suppressions.cc
asan_suppressions.h
asan_thread.cc
asan_thread.h
asan_win.cc
asan_win_dll_thunk.cc
asan_win_dynamic_runtime_thunk.cc
asan_win_weak_interception.cc
libtool-version