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 Revert 2018-07-05 11:47:05 +02:00
Makefile.in Revert 2018-07-05 11:47:05 +02:00
asan_activation.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_activation.h libsanitizer merge from upstream r250806. 2015-10-21 10:32:45 +03:00
asan_activation_flags.inc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_allocator.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
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 All source files: Merge from upstream 285547. 2016-11-09 00:04:09 +02:00
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 ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_errors.h ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_fake_stack.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_fake_stack.h All source files: Merge from upstream 285547. 2016-11-09 00:04:09 +02:00
asan_flags.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_flags.h libsanitizer merge from upstream r250806. 2015-10-21 10:32:45 +03:00
asan_flags.inc Cherry-pick libsanitizer pointer-pair tristate option. 2018-02-05 11:01:50 +00:00
asan_fuchsia.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_globals.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_globals_win.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_init_version.h All source files: Merge from upstream 285547. 2016-11-09 00:04:09 +02:00
asan_interceptors.cc libsanitizer: Mark REAL(swapcontext) with indirect_return attribute on x86 2018-07-26 07:48:55 -07:00
asan_interceptors.h ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_interceptors_memintrinsics.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_interceptors_memintrinsics.h ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_interface.inc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_interface_internal.h ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_internal.h ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_linux.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_lock.h libsanitizer merge from upstream r173241 2013-01-23 11:41:33 +00:00
asan_mac.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_malloc_linux.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_malloc_mac.cc All source files: Merge from upstream 285547. 2016-11-09 00:04:09 +02:00
asan_malloc_win.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_mapping.h ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_memory_profile.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_new_delete.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_poisoning.cc [libsanitizer] Remove semicolon after do {} while (0) in macro body 2017-11-05 09:57:17 +00:00
asan_poisoning.h ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_posix.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_preinit.cc libsanitizer merge from upstream r250806. 2015-10-21 10:32:45 +03:00
asan_report.cc Cherry-pick libsanitizer pointer-pair tristate option. 2018-02-05 11:01:50 +00:00
asan_report.h ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_rtl.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_scariness_score.h ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_shadow_setup.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_stack.cc libsanitizer merge from upstream r250806. 2015-10-21 10:32:45 +03:00
asan_stack.h ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_stats.cc libsanitizer merge from upstream r250806. 2015-10-21 10:32:45 +03:00
asan_stats.h libsanitizer merge from upstream r250806. 2015-10-21 10:32:45 +03:00
asan_suppressions.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_suppressions.h libsanitizer merge from upstream r250806. 2015-10-21 10:32:45 +03:00
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.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_win_dll_thunk.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_win_dynamic_runtime_thunk.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
asan_win_weak_interception.cc ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00
libtool-version ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins... 2017-10-19 13:23:59 +02:00