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
..
asan_activation_flags.inc
asan_activation.cc
asan_activation.h
asan_allocator.cc
asan_allocator.h re PR sanitizer/85389 (posix_memalign() crash with address sanitizer when passing invalid arguments) 2018-04-18 09:02:40 +02:00
asan_debugging.cc
asan_descriptions.cc invoke.texi: Document the options. 2017-12-05 10:23:25 +01:00
asan_descriptions.h invoke.texi: Document the options. 2017-12-05 10:23:25 +01:00
asan_errors.cc
asan_errors.h
asan_fake_stack.cc
asan_fake_stack.h
asan_flags.cc
asan_flags.h
asan_flags.inc Cherry-pick libsanitizer pointer-pair tristate option. 2018-02-05 11:01:50 +00:00
asan_fuchsia.cc
asan_globals_win.cc
asan_globals.cc
asan_init_version.h
asan_interceptors_memintrinsics.cc
asan_interceptors_memintrinsics.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_interface_internal.h
asan_interface.inc
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 Cherry-pick libsanitizer pointer-pair tristate option. 2018-02-05 11:01:50 +00:00
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 invoke.texi: Document the options. 2017-12-05 10:23:25 +01:00
asan_thread.h invoke.texi: Document the options. 2017-12-05 10:23:25 +01:00
asan_win_dll_thunk.cc
asan_win_dynamic_runtime_thunk.cc
asan_win_weak_interception.cc
asan_win.cc
libtool-version
Makefile.am Revert 2018-07-05 11:47:05 +02:00
Makefile.in Revert 2018-07-05 11:47:05 +02:00