summaryrefslogtreecommitdiffstats
path: root/libsanitizer
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-09-27 10:43:33 -0700
committerH.J. Lu <hjl.tools@gmail.com>2021-10-01 09:02:54 -0700
commit76288e1c5da5a34e3c13d37ac4cab41e0f46ff61 (patch)
tree91841423d03755f702c6a60401338e06c08c8017 /libsanitizer
parentc++: cv-qualified ref introduced by typedef [PR101783] (diff)
downloadgcc-76288e1c5da5a34e3c13d37ac4cab41e0f46ff61.tar.gz
gcc-76288e1c5da5a34e3c13d37ac4cab41e0f46ff61.tar.bz2
gcc-76288e1c5da5a34e3c13d37ac4cab41e0f46ff61.tar.xz
libsanitizer: Merge with upstream
Merged revision: 1c2e5fd66ea27d0c51360ba4e22099124a915562
Diffstat (limited to 'libsanitizer')
-rw-r--r--libsanitizer/MERGE2
-rw-r--r--libsanitizer/asan/asan_fuchsia.cpp35
-rw-r--r--libsanitizer/asan/asan_globals.cpp33
-rw-r--r--libsanitizer/asan/asan_interceptors.cpp18
-rw-r--r--libsanitizer/asan/asan_interceptors.h52
-rw-r--r--libsanitizer/asan/asan_mapping.h2
-rw-r--r--libsanitizer/asan/asan_report.cpp10
-rw-r--r--libsanitizer/asan/asan_rtl.cpp18
-rw-r--r--libsanitizer/asan/asan_stats.cpp10
-rw-r--r--libsanitizer/asan/asan_thread.cpp4
-rw-r--r--libsanitizer/hwasan/Makefile.am3
-rw-r--r--libsanitizer/hwasan/Makefile.in12
-rw-r--r--libsanitizer/hwasan/hwasan.cpp3
-rw-r--r--libsanitizer/hwasan/hwasan.h25
-rw-r--r--libsanitizer/hwasan/hwasan_allocation_functions.cpp24
-rw-r--r--libsanitizer/hwasan/hwasan_allocator.cpp58
-rw-r--r--libsanitizer/hwasan/hwasan_dynamic_shadow.cpp9
-rw-r--r--libsanitizer/hwasan/hwasan_fuchsia.cpp23
-rw-r--r--libsanitizer/hwasan/hwasan_interceptors.cpp70
-rw-r--r--libsanitizer/hwasan/hwasan_interface_internal.h48
-rw-r--r--libsanitizer/hwasan/hwasan_linux.cpp147
-rw-r--r--libsanitizer/hwasan/hwasan_report.cpp82
-rw-r--r--libsanitizer/hwasan/hwasan_setjmp_aarch64.S (renamed from libsanitizer/hwasan/hwasan_setjmp.S)21
-rw-r--r--libsanitizer/hwasan/hwasan_setjmp_x86_64.S80
-rw-r--r--libsanitizer/hwasan/hwasan_thread.cpp2
-rw-r--r--libsanitizer/hwasan/hwasan_type_test.cpp2
-rw-r--r--libsanitizer/include/sanitizer/asan_interface.h2
-rw-r--r--libsanitizer/include/sanitizer/common_interface_defs.h2
-rw-r--r--libsanitizer/include/sanitizer/dfsan_interface.h3
-rw-r--r--libsanitizer/include/sanitizer/linux_syscall_hooks.h2120
-rw-r--r--libsanitizer/include/sanitizer/tsan_interface.h3
-rw-r--r--libsanitizer/interception/interception_win.cpp48
-rw-r--r--libsanitizer/lsan/lsan_allocator.h2
-rw-r--r--libsanitizer/lsan/lsan_common.cpp12
-rw-r--r--libsanitizer/sanitizer_common/sancov_flags.inc2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_addrhashmap.h2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_allocator_primary64.h14
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_allocator_size_class_map.h8
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_asm.h4
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_atomic_clang_mips.h2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_common.h20
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc652
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_common_interceptors_format.inc10
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_common_interceptors_netbsd_compat.inc4
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_common_nolibc.cpp1
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_common_syscalls.inc1559
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_coverage_fuchsia.cpp8
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_coverage_libcdep_new.cpp65
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_file.cpp15
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_file.h2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_flag_parser.h2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_flags.inc4
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_fuchsia.cpp41
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_interface_internal.h7
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_internal_defs.h46
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_libc.cpp12
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_libc.h5
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_libignore.cpp33
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_libignore.h37
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_linux.cpp83
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp4
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_local_address_space_view.h2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_mac.cpp41
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_mac.h20
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_mutex.cpp186
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_mutex.h325
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_platform.h25
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h27
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_platform_limits_freebsd.cpp4
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_platform_limits_freebsd.h164
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cpp61
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cpp1
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h1
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp25
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h32
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_platform_limits_solaris.cpp1
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_platform_limits_solaris.h1
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_posix.h7
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_printf.cpp37
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_signal_interceptors.inc12
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_solaris.cpp22
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_stacktrace.cpp22
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_stacktrace_libcdep.cpp2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_stacktrace_printer.cpp11
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cpp2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_symbolizer.h6
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_symbolizer_internal.h2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_symbolizer_libcdep.cpp12
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_syscall_linux_hexagon.inc131
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_thread_registry.cpp22
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_thread_registry.h2
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_tls_get_addr.cpp19
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_win.cpp24
-rw-r--r--libsanitizer/tsan/Makefile.am4
-rw-r--r--libsanitizer/tsan/Makefile.in13
-rw-r--r--libsanitizer/tsan/tsan_clock.cpp10
-rw-r--r--libsanitizer/tsan/tsan_clock.h2
-rw-r--r--libsanitizer/tsan/tsan_debugging.cpp10
-rw-r--r--libsanitizer/tsan/tsan_defs.h66
-rw-r--r--libsanitizer/tsan/tsan_dense_alloc.h35
-rw-r--r--libsanitizer/tsan/tsan_external.cpp19
-rw-r--r--libsanitizer/tsan/tsan_fd.cpp24
-rw-r--r--libsanitizer/tsan/tsan_fd.h2
-rw-r--r--libsanitizer/tsan/tsan_flags.cpp1
-rw-r--r--libsanitizer/tsan/tsan_flags.inc1
-rw-r--r--libsanitizer/tsan/tsan_ignoreset.cpp12
-rw-r--r--libsanitizer/tsan/tsan_ignoreset.h13
-rw-r--r--libsanitizer/tsan/tsan_ilist.h189
-rw-r--r--libsanitizer/tsan/tsan_interceptors.h35
-rw-r--r--libsanitizer/tsan/tsan_interceptors_mac.cpp6
-rw-r--r--libsanitizer/tsan/tsan_interceptors_posix.cpp417
-rw-r--r--libsanitizer/tsan/tsan_interface.cpp96
-rw-r--r--libsanitizer/tsan/tsan_interface.h10
-rw-r--r--libsanitizer/tsan/tsan_interface.inc182
-rw-r--r--libsanitizer/tsan/tsan_interface_ann.cpp172
-rw-r--r--libsanitizer/tsan/tsan_interface_atomic.cpp323
-rw-r--r--libsanitizer/tsan/tsan_interface_inl.h133
-rw-r--r--libsanitizer/tsan/tsan_interface_java.cpp291
-rw-r--r--libsanitizer/tsan/tsan_mman.cpp10
-rw-r--r--libsanitizer/tsan/tsan_mman.h49
-rw-r--r--libsanitizer/tsan/tsan_mutex.cpp280
-rw-r--r--libsanitizer/tsan/tsan_mutex.h87
-rw-r--r--libsanitizer/tsan/tsan_mutexset.cpp47
-rw-r--r--libsanitizer/tsan/tsan_mutexset.h29
-rw-r--r--libsanitizer/tsan/tsan_platform.h1089
-rw-r--r--libsanitizer/tsan/tsan_platform_linux.cpp109
-rw-r--r--libsanitizer/tsan/tsan_platform_mac.cpp22
-rw-r--r--libsanitizer/tsan/tsan_platform_posix.cpp37
-rw-r--r--libsanitizer/tsan/tsan_platform_windows.cpp3
-rw-r--r--libsanitizer/tsan/tsan_report.cpp77
-rw-r--r--libsanitizer/tsan/tsan_report.h36
-rw-r--r--libsanitizer/tsan/tsan_rtl.cpp477
-rw-r--r--libsanitizer/tsan/tsan_rtl.h499
-rw-r--r--libsanitizer/tsan/tsan_rtl_mutex.cpp419
-rw-r--r--libsanitizer/tsan/tsan_rtl_ppc64.S1
-rw-r--r--libsanitizer/tsan/tsan_rtl_report.cpp328
-rw-r--r--libsanitizer/tsan/tsan_rtl_thread.cpp306
-rw-r--r--libsanitizer/tsan/tsan_shadow.h233
-rw-r--r--libsanitizer/tsan/tsan_stack_trace.cpp12
-rw-r--r--libsanitizer/tsan/tsan_symbolize.cpp3
-rw-r--r--libsanitizer/tsan/tsan_sync.cpp58
-rw-r--r--libsanitizer/tsan/tsan_sync.h36
-rw-r--r--libsanitizer/tsan/tsan_trace.h153
-rw-r--r--libsanitizer/tsan/tsan_update_shadow_word.inc (renamed from libsanitizer/tsan/tsan_update_shadow_word_inl.h)2
-rw-r--r--libsanitizer/tsan/tsan_vector_clock.cpp126
-rw-r--r--libsanitizer/tsan/tsan_vector_clock.h51
-rw-r--r--libsanitizer/ubsan/ubsan_diag.cpp8
-rw-r--r--libsanitizer/ubsan/ubsan_flags.cpp1
-rw-r--r--libsanitizer/ubsan/ubsan_handlers.cpp15
-rw-r--r--libsanitizer/ubsan/ubsan_handlers.h8
-rw-r--r--libsanitizer/ubsan/ubsan_platform.h2
155 files changed, 7454 insertions, 6109 deletions
diff --git a/libsanitizer/MERGE b/libsanitizer/MERGE
index 81d00f27de4..2094a8beb3e 100644
--- a/libsanitizer/MERGE
+++ b/libsanitizer/MERGE
@@ -1,4 +1,4 @@
17704fedfff6ef5676adb6415f3be0ac927d1a746 11c2e5fd66ea27d0c51360ba4e22099124a915562
2 2
3The first line of this file holds the git revision number of the 3The first line of this file holds the git revision number of the
4last merge done from the master library sources. 4last merge done from the master library sources.
diff --git a/libsanitizer/asan/asan_fuchsia.cpp b/libsanitizer/asan/asan_fuchsia.cpp
index b0c7255144a..b419019d137 100644
--- a/libsanitizer/asan/asan_fuchsia.cpp
+++ b/libsanitizer/asan/asan_fuchsia.cpp
@@ -31,7 +31,8 @@ namespace __asan {
31// AsanInitInternal->InitializeHighMemEnd (asan_rtl.cpp). 31// AsanInitInternal->InitializeHighMemEnd (asan_rtl.cpp).
32// Just do some additional sanity checks here. 32// Just do some additional sanity checks here.
33void InitializeShadowMemory() { 33void InitializeShadowMemory() {
34 if (Verbosity()) PrintAddressSpaceLayout(); 34 if (Verbosity())
35 PrintAddressSpaceLayout();
35 36
36 // Make sure SHADOW_OFFSET doesn't use __asan_shadow_memory_dynamic_address. 37 // Make sure SHADOW_OFFSET doesn't use __asan_shadow_memory_dynamic_address.
37 __asan_shadow_memory_dynamic_address = kDefaultShadowSentinel; 38 __asan_shadow_memory_dynamic_address = kDefaultShadowSentinel;
@@ -62,7 +63,34 @@ void AsanOnDeadlySignal(int signo, void *siginfo, void *context) {
62 UNIMPLEMENTED(); 63 UNIMPLEMENTED();
63} 64}
64 65
65bool PlatformUnpoisonStacks() { return false; } 66bool PlatformUnpoisonStacks() {
67 // The current sp might not point to the default stack. This
68 // could be because we are in a crash stack from fuzzing for example.
69 // Unpoison the default stack and the current stack page.
70 AsanThread *curr_thread = GetCurrentThread();
71 CHECK(curr_thread != nullptr);
72 uptr top = curr_thread->stack_top();
73 uptr bottom = curr_thread->stack_bottom();
74 // The default stack grows from top to bottom. (bottom < top).
75
76 uptr local_stack = reinterpret_cast<uptr>(__builtin_frame_address(0));
77 if (local_stack >= bottom && local_stack <= top) {
78 // The current stack is the default stack.
79 // We only need to unpoison from where we are using until the end.
80 bottom = RoundDownTo(local_stack, GetPageSize());
81 UnpoisonStack(bottom, top, "default");
82 } else {
83 // The current stack is not the default stack.
84 // Unpoison the entire default stack and the current stack page.
85 UnpoisonStack(bottom, top, "default");
86 bottom = RoundDownTo(local_stack, GetPageSize());
87 top = bottom + GetPageSize();
88 UnpoisonStack(bottom, top, "unknown");
89 return true;
90 }
91
92 return false;
93}
66 94
67// We can use a plain thread_local variable for TSD. 95// We can use a plain thread_local variable for TSD.
68static thread_local void *per_thread; 96static thread_local void *per_thread;
@@ -148,7 +176,8 @@ static void *BeforeThreadCreateHook(uptr user_id, bool detached,
148 uptr stack_size) { 176 uptr stack_size) {
149 EnsureMainThreadIDIsCorrect(); 177 EnsureMainThreadIDIsCorrect();
150 // Strict init-order checking is thread-hostile. 178 // Strict init-order checking is thread-hostile.
151 if (flags()->strict_init_order) StopInitOrderChecking(); 179 if (flags()->strict_init_order)
180 StopInitOrderChecking();
152 181
153 GET_STACK_TRACE_THREAD; 182 GET_STACK_TRACE_THREAD;
154 u32 parent_tid = GetCurrentTidOrInvalid(); 183 u32 parent_tid = GetCurrentTidOrInvalid();
diff --git a/libsanitizer/asan/asan_globals.cpp b/libsanitizer/asan/asan_globals.cpp
index e045c31cd1c..9bf378f6207 100644
--- a/libsanitizer/asan/asan_globals.cpp
+++ b/libsanitizer/asan/asan_globals.cpp
@@ -35,7 +35,7 @@ struct ListOfGlobals {
35 ListOfGlobals *next; 35 ListOfGlobals *next;
36}; 36};
37 37
38static BlockingMutex mu_for_globals(LINKER_INITIALIZED); 38static Mutex mu_for_globals;
39static LowLevelAllocator allocator_for_globals; 39static LowLevelAllocator allocator_for_globals;
40static ListOfGlobals *list_of_all_globals; 40static ListOfGlobals *list_of_all_globals;
41 41
@@ -108,7 +108,7 @@ static u32 FindRegistrationSite(const Global *g) {
108int GetGlobalsForAddress(uptr addr, Global *globals, u32 *reg_sites, 108int GetGlobalsForAddress(uptr addr, Global *globals, u32 *reg_sites,
109 int max_globals) { 109 int max_globals) {
110 if (!flags()->report_globals) return 0; 110 if (!flags()->report_globals) return 0;
111 BlockingMutexLock lock(&mu_for_globals); 111 Lock lock(&mu_for_globals);
112 int res = 0; 112 int res = 0;
113 for (ListOfGlobals *l = list_of_all_globals; l; l = l->next) { 113 for (ListOfGlobals *l = list_of_all_globals; l; l = l->next) {
114 const Global &g = *l->g; 114 const Global &g = *l->g;
@@ -154,6 +154,23 @@ static void CheckODRViolationViaIndicator(const Global *g) {
154 } 154 }
155} 155}
156 156
157// Check ODR violation for given global G by checking if it's already poisoned.
158// We use this method in case compiler doesn't use private aliases for global
159// variables.
160static void CheckODRViolationViaPoisoning(const Global *g) {
161 if (__asan_region_is_poisoned(g->beg, g->size_with_redzone)) {
162 // This check may not be enough: if the first global is much larger
163 // the entire redzone of the second global may be within the first global.
164 for (ListOfGlobals *l = list_of_all_globals; l; l = l->next) {
165 if (g->beg == l->g->beg &&
166 (flags()->detect_odr_violation >= 2 || g->size != l->g->size) &&
167 !IsODRViolationSuppressed(g->name))
168 ReportODRViolation(g, FindRegistrationSite(g),
169 l->g, FindRegistrationSite(l->g));
170 }
171 }
172}
173
157// Clang provides two different ways for global variables protection: 174// Clang provides two different ways for global variables protection:
158// it can poison the global itself or its private alias. In former 175// it can poison the global itself or its private alias. In former
159// case we may poison same symbol multiple times, that can help us to 176// case we may poison same symbol multiple times, that can help us to
@@ -199,6 +216,8 @@ static void RegisterGlobal(const Global *g) {
199 // where two globals with the same name are defined in different modules. 216 // where two globals with the same name are defined in different modules.
200 if (UseODRIndicator(g)) 217 if (UseODRIndicator(g))
201 CheckODRViolationViaIndicator(g); 218 CheckODRViolationViaIndicator(g);
219 else
220 CheckODRViolationViaPoisoning(g);
202 } 221 }
203 if (CanPoisonMemory()) 222 if (CanPoisonMemory())
204 PoisonRedZones(*g); 223 PoisonRedZones(*g);
@@ -238,7 +257,7 @@ static void UnregisterGlobal(const Global *g) {
238} 257}
239 258
240void StopInitOrderChecking() { 259void StopInitOrderChecking() {
241 BlockingMutexLock lock(&mu_for_globals); 260 Lock lock(&mu_for_globals);
242 if (!flags()->check_initialization_order || !dynamic_init_globals) 261 if (!flags()->check_initialization_order || !dynamic_init_globals)
243 return; 262 return;
244 flags()->check_initialization_order = false; 263 flags()->check_initialization_order = false;
@@ -340,7 +359,7 @@ void __asan_register_globals(__asan_global *globals, uptr n) {
340 if (!flags()->report_globals) return; 359 if (!flags()->report_globals) return;
341 GET_STACK_TRACE_MALLOC; 360 GET_STACK_TRACE_MALLOC;
342 u32 stack_id = StackDepotPut(stack); 361 u32 stack_id = StackDepotPut(stack);
343 BlockingMutexLock lock(&mu_for_globals); 362 Lock lock(&mu_for_globals);
344 if (!global_registration_site_vector) { 363 if (!global_registration_site_vector) {
345 global_registration_site_vector = 364 global_registration_site_vector =
346 new (allocator_for_globals) GlobalRegistrationSiteVector; 365 new (allocator_for_globals) GlobalRegistrationSiteVector;
@@ -379,7 +398,7 @@ void __asan_register_globals(__asan_global *globals, uptr n) {
379// We must do this when a shared objects gets dlclosed. 398// We must do this when a shared objects gets dlclosed.
380void __asan_unregister_globals(__asan_global *globals, uptr n) { 399void __asan_unregister_globals(__asan_global *globals, uptr n) {
381 if (!flags()->report_globals) return; 400 if (!flags()->report_globals) return;
382 BlockingMutexLock lock(&mu_for_globals); 401 Lock lock(&mu_for_globals);
383 for (uptr i = 0; i < n; i++) { 402 for (uptr i = 0; i < n; i++) {
384 if (SANITIZER_WINDOWS && globals[i].beg == 0) { 403 if (SANITIZER_WINDOWS && globals[i].beg == 0) {
385 // Skip globals that look like padding from the MSVC incremental linker. 404 // Skip globals that look like padding from the MSVC incremental linker.
@@ -405,7 +424,7 @@ void __asan_before_dynamic_init(const char *module_name) {
405 bool strict_init_order = flags()->strict_init_order; 424 bool strict_init_order = flags()->strict_init_order;
406 CHECK(module_name); 425 CHECK(module_name);
407 CHECK(asan_inited); 426 CHECK(asan_inited);
408 BlockingMutexLock lock(&mu_for_globals); 427 Lock lock(&mu_for_globals);
409 if (flags()->report_globals >= 3) 428 if (flags()->report_globals >= 3)
410 Printf("DynInitPoison module: %s\n", module_name); 429 Printf("DynInitPoison module: %s\n", module_name);
411 for (uptr i = 0, n = dynamic_init_globals->size(); i < n; ++i) { 430 for (uptr i = 0, n = dynamic_init_globals->size(); i < n; ++i) {
@@ -429,7 +448,7 @@ void __asan_after_dynamic_init() {
429 !dynamic_init_globals) 448 !dynamic_init_globals)
430 return; 449 return;
431 CHECK(asan_inited); 450 CHECK(asan_inited);
432 BlockingMutexLock lock(&mu_for_globals); 451 Lock lock(&mu_for_globals);
433 // FIXME: Optionally report that we're unpoisoning globals from a module. 452 // FIXME: Optionally report that we're unpoisoning globals from a module.
434 for (uptr i = 0, n = dynamic_init_globals->size(); i < n; ++i) { 453 for (uptr i = 0, n = dynamic_init_globals->size(); i < n; ++i) {
435 DynInitGlobal &dyn_g = (*dynamic_init_globals)[i]; 454 DynInitGlobal &dyn_g = (*dynamic_init_globals)[i];
diff --git a/libsanitizer/asan/asan_interceptors.cpp b/libsanitizer/asan/asan_interceptors.cpp
index d0a6dd48a74..b28909152e2 100644
--- a/libsanitizer/asan/asan_interceptors.cpp
+++ b/libsanitizer/asan/asan_interceptors.cpp
@@ -49,8 +49,8 @@ namespace __asan {
49 ASAN_READ_RANGE((ctx), (s), \ 49 ASAN_READ_RANGE((ctx), (s), \
50 common_flags()->strict_string_checks ? (len) + 1 : (n)) 50 common_flags()->strict_string_checks ? (len) + 1 : (n))
51 51
52#define ASAN_READ_STRING(ctx, s, n) \ 52# define ASAN_READ_STRING(ctx, s, n) \
53 ASAN_READ_STRING_OF_LEN((ctx), (s), REAL(strlen)(s), (n)) 53 ASAN_READ_STRING_OF_LEN((ctx), (s), internal_strlen(s), (n))
54 54
55static inline uptr MaybeRealStrnlen(const char *s, uptr maxlen) { 55static inline uptr MaybeRealStrnlen(const char *s, uptr maxlen) {
56#if SANITIZER_INTERCEPT_STRNLEN 56#if SANITIZER_INTERCEPT_STRNLEN
@@ -370,9 +370,9 @@ DEFINE_REAL(char*, index, const char *string, int c)
370 ASAN_INTERCEPTOR_ENTER(ctx, strcat); 370 ASAN_INTERCEPTOR_ENTER(ctx, strcat);
371 ENSURE_ASAN_INITED(); 371 ENSURE_ASAN_INITED();
372 if (flags()->replace_str) { 372 if (flags()->replace_str) {
373 uptr from_length = REAL(strlen)(from); 373 uptr from_length = internal_strlen(from);
374 ASAN_READ_RANGE(ctx, from, from_length + 1); 374 ASAN_READ_RANGE(ctx, from, from_length + 1);
375 uptr to_length = REAL(strlen)(to); 375 uptr to_length = internal_strlen(to);
376 ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length); 376 ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length);
377 ASAN_WRITE_RANGE(ctx, to + to_length, from_length + 1); 377 ASAN_WRITE_RANGE(ctx, to + to_length, from_length + 1);
378 // If the copying actually happens, the |from| string should not overlap 378 // If the copying actually happens, the |from| string should not overlap
@@ -394,7 +394,7 @@ INTERCEPTOR(char*, strncat, char *to, const char *from, uptr size) {
394 uptr from_length = MaybeRealStrnlen(from, size); 394 uptr from_length = MaybeRealStrnlen(from, size);
395 uptr copy_length = Min(size, from_length + 1); 395 uptr copy_length = Min(size, from_length + 1);
396 ASAN_READ_RANGE(ctx, from, copy_length); 396 ASAN_READ_RANGE(ctx, from, copy_length);
397 uptr to_length = REAL(strlen)(to); 397 uptr to_length = internal_strlen(to);
398 ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length); 398 ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length);
399 ASAN_WRITE_RANGE(ctx, to + to_length, from_length + 1); 399 ASAN_WRITE_RANGE(ctx, to + to_length, from_length + 1);
400 if (from_length > 0) { 400 if (from_length > 0) {
@@ -419,7 +419,7 @@ INTERCEPTOR(char *, strcpy, char *to, const char *from) {
419 } 419 }
420 ENSURE_ASAN_INITED(); 420 ENSURE_ASAN_INITED();
421 if (flags()->replace_str) { 421 if (flags()->replace_str) {
422 uptr from_size = REAL(strlen)(from) + 1; 422 uptr from_size = internal_strlen(from) + 1;
423 CHECK_RANGES_OVERLAP("strcpy", to, from_size, from, from_size); 423 CHECK_RANGES_OVERLAP("strcpy", to, from_size, from, from_size);
424 ASAN_READ_RANGE(ctx, from, from_size); 424 ASAN_READ_RANGE(ctx, from, from_size);
425 ASAN_WRITE_RANGE(ctx, to, from_size); 425 ASAN_WRITE_RANGE(ctx, to, from_size);
@@ -432,7 +432,7 @@ INTERCEPTOR(char*, strdup, const char *s) {
432 ASAN_INTERCEPTOR_ENTER(ctx, strdup); 432 ASAN_INTERCEPTOR_ENTER(ctx, strdup);
433 if (UNLIKELY(!asan_inited)) return internal_strdup(s); 433 if (UNLIKELY(!asan_inited)) return internal_strdup(s);
434 ENSURE_ASAN_INITED(); 434 ENSURE_ASAN_INITED();
435 uptr length = REAL(strlen)(s); 435 uptr length = internal_strlen(s);
436 if (flags()->replace_str) { 436 if (flags()->replace_str) {
437 ASAN_READ_RANGE(ctx, s, length + 1); 437 ASAN_READ_RANGE(ctx, s, length + 1);
438 } 438 }
@@ -448,7 +448,7 @@ INTERCEPTOR(char*, __strdup, const char *s) {
448 ASAN_INTERCEPTOR_ENTER(ctx, strdup); 448 ASAN_INTERCEPTOR_ENTER(ctx, strdup);
449 if (UNLIKELY(!asan_inited)) return internal_strdup(s); 449 if (UNLIKELY(!asan_inited)) return internal_strdup(s);
450 ENSURE_ASAN_INITED(); 450 ENSURE_ASAN_INITED();
451 uptr length = REAL(strlen)(s); 451 uptr length = internal_strlen(s);
452 if (flags()->replace_str) { 452 if (flags()->replace_str) {
453 ASAN_READ_RANGE(ctx, s, length + 1); 453 ASAN_READ_RANGE(ctx, s, length + 1);
454 } 454 }
@@ -581,7 +581,7 @@ INTERCEPTOR(int, atexit, void (*func)()) {
581#if CAN_SANITIZE_LEAKS 581#if CAN_SANITIZE_LEAKS
582 __lsan::ScopedInterceptorDisabler disabler; 582 __lsan::ScopedInterceptorDisabler disabler;
583#endif 583#endif
584 // Avoid calling real atexit as it is unrechable on at least on Linux. 584 // Avoid calling real atexit as it is unreachable on at least on Linux.
585 int res = REAL(__cxa_atexit)((void (*)(void *a))func, nullptr, nullptr); 585 int res = REAL(__cxa_atexit)((void (*)(void *a))func, nullptr, nullptr);
586 REAL(__cxa_atexit)(AtCxaAtexit, nullptr, nullptr); 586 REAL(__cxa_atexit)(AtCxaAtexit, nullptr, nullptr);
587 return res; 587 return res;
diff --git a/libsanitizer/asan/asan_interceptors.h b/libsanitizer/asan/asan_interceptors.h
index 25e05e458be..047b044c8bf 100644
--- a/libsanitizer/asan/asan_interceptors.h
+++ b/libsanitizer/asan/asan_interceptors.h
@@ -81,12 +81,7 @@ void InitializePlatformInterceptors();
81#if ASAN_HAS_EXCEPTIONS && !SANITIZER_WINDOWS && !SANITIZER_SOLARIS && \ 81#if ASAN_HAS_EXCEPTIONS && !SANITIZER_WINDOWS && !SANITIZER_SOLARIS && \
82 !SANITIZER_NETBSD 82 !SANITIZER_NETBSD
83# define ASAN_INTERCEPT___CXA_THROW 1 83# define ASAN_INTERCEPT___CXA_THROW 1
84# if ! defined(ASAN_HAS_CXA_RETHROW_PRIMARY_EXCEPTION) \ 84# define ASAN_INTERCEPT___CXA_RETHROW_PRIMARY_EXCEPTION 1
85 || ASAN_HAS_CXA_RETHROW_PRIMARY_EXCEPTION
86# define ASAN_INTERCEPT___CXA_RETHROW_PRIMARY_EXCEPTION 1
87# else
88# define ASAN_INTERCEPT___CXA_RETHROW_PRIMARY_EXCEPTION 0
89# endif
90# if defined(_GLIBCXX_SJLJ_EXCEPTIONS) || (SANITIZER_IOS && defined(__arm__)) 85# if defined(_GLIBCXX_SJLJ_EXCEPTIONS) || (SANITIZER_IOS && defined(__arm__))
91# define ASAN_INTERCEPT__UNWIND_SJLJ_RAISEEXCEPTION 1 86# define ASAN_INTERCEPT__UNWIND_SJLJ_RAISEEXCEPTION 1
92# else 87# else
@@ -138,29 +133,30 @@ DECLARE_REAL(char*, strncpy, char *to, const char *from, uptr size)
138DECLARE_REAL(uptr, strnlen, const char *s, uptr maxlen) 133DECLARE_REAL(uptr, strnlen, const char *s, uptr maxlen)
139DECLARE_REAL(char*, strstr, const char *s1, const char *s2) 134DECLARE_REAL(char*, strstr, const char *s1, const char *s2)
140 135
141#if !SANITIZER_MAC 136# if !SANITIZER_MAC
142#define ASAN_INTERCEPT_FUNC(name) \ 137# define ASAN_INTERCEPT_FUNC(name) \
143 do { \ 138 do { \
144 if (!INTERCEPT_FUNCTION(name)) \ 139 if (!INTERCEPT_FUNCTION(name)) \
145 VReport(1, "AddressSanitizer: failed to intercept '%s'\n", #name); \ 140 VReport(1, "AddressSanitizer: failed to intercept '%s'\n", #name); \
146 } while (0) 141 } while (0)
147#define ASAN_INTERCEPT_FUNC_VER(name, ver) \ 142# define ASAN_INTERCEPT_FUNC_VER(name, ver) \
148 do { \ 143 do { \
149 if (!INTERCEPT_FUNCTION_VER(name, ver)) \ 144 if (!INTERCEPT_FUNCTION_VER(name, ver)) \
150 VReport(1, "AddressSanitizer: failed to intercept '%s@@%s'\n", #name, \ 145 VReport(1, "AddressSanitizer: failed to intercept '%s@@%s'\n", \
151 #ver); \ 146 #name, ver); \
152 } while (0) 147 } while (0)
153#define ASAN_INTERCEPT_FUNC_VER_UNVERSIONED_FALLBACK(name, ver) \ 148# define ASAN_INTERCEPT_FUNC_VER_UNVERSIONED_FALLBACK(name, ver) \
154 do { \ 149 do { \
155 if (!INTERCEPT_FUNCTION_VER(name, ver) && !INTERCEPT_FUNCTION(name)) \ 150 if (!INTERCEPT_FUNCTION_VER(name, ver) && !INTERCEPT_FUNCTION(name)) \
156 VReport(1, "AddressSanitizer: failed to intercept '%s@@%s' or '%s'\n", \ 151 VReport(1, \
157 #name, #ver, #name); \ 152 "AddressSanitizer: failed to intercept '%s@@%s' or '%s'\n", \
158 } while (0) 153 #name, ver, #name); \
159 154 } while (0)
160#else 155
156# else
161// OS X interceptors don't need to be initialized with INTERCEPT_FUNCTION. 157// OS X interceptors don't need to be initialized with INTERCEPT_FUNCTION.
162#define ASAN_INTERCEPT_FUNC(name) 158# define ASAN_INTERCEPT_FUNC(name)
163#endif // SANITIZER_MAC 159# endif // SANITIZER_MAC
164 160
165#endif // !SANITIZER_FUCHSIA 161#endif // !SANITIZER_FUCHSIA
166 162
diff --git a/libsanitizer/asan/asan_mapping.h b/libsanitizer/asan/asan_mapping.h
index 4b0037fced3..e5a7f2007ae 100644
--- a/libsanitizer/asan/asan_mapping.h
+++ b/libsanitizer/asan/asan_mapping.h
@@ -165,7 +165,7 @@ static const u64 kAArch64_ShadowOffset64 = 1ULL << 36;
165static const u64 kRiscv64_ShadowOffset64 = 0xd55550000; 165static const u64 kRiscv64_ShadowOffset64 = 0xd55550000;
166static const u64 kMIPS32_ShadowOffset32 = 0x0aaa0000; 166static const u64 kMIPS32_ShadowOffset32 = 0x0aaa0000;
167static const u64 kMIPS64_ShadowOffset64 = 1ULL << 37; 167static const u64 kMIPS64_ShadowOffset64 = 1ULL << 37;
168static const u64 kPPC64_ShadowOffset64 = 1ULL << 41; 168static const u64 kPPC64_ShadowOffset64 = 1ULL << 44;
169static const u64 kSystemZ_ShadowOffset64 = 1ULL << 52; 169static const u64 kSystemZ_ShadowOffset64 = 1ULL << 52;
170static const u64 kSPARC64_ShadowOffset64 = 1ULL << 43; // 0x80000000000 170static const u64 kSPARC64_ShadowOffset64 = 1ULL << 43; // 0x80000000000
171static const u64 kFreeBSD_ShadowOffset32 = 1ULL << 30; // 0x40000000 171static const u64 kFreeBSD_ShadowOffset32 = 1ULL << 30; // 0x40000000
diff --git a/libsanitizer/asan/asan_report.cpp b/libsanitizer/asan/asan_report.cpp
index 03f1ed2b018..271d8964038 100644
--- a/libsanitizer/asan/asan_report.cpp
+++ b/libsanitizer/asan/asan_report.cpp
@@ -32,12 +32,12 @@ namespace __asan {
32static void (*error_report_callback)(const char*); 32static void (*error_report_callback)(const char*);
33static char *error_message_buffer = nullptr; 33static char *error_message_buffer = nullptr;
34static uptr error_message_buffer_pos = 0; 34static uptr error_message_buffer_pos = 0;
35static BlockingMutex error_message_buf_mutex(LINKER_INITIALIZED); 35static Mutex error_message_buf_mutex;
36static const unsigned kAsanBuggyPcPoolSize = 25; 36static const unsigned kAsanBuggyPcPoolSize = 25;
37static __sanitizer::atomic_uintptr_t AsanBuggyPcPool[kAsanBuggyPcPoolSize]; 37static __sanitizer::atomic_uintptr_t AsanBuggyPcPool[kAsanBuggyPcPoolSize];
38 38
39void AppendToErrorMessageBuffer(const char *buffer) { 39void AppendToErrorMessageBuffer(const char *buffer) {
40 BlockingMutexLock l(&error_message_buf_mutex); 40 Lock l(&error_message_buf_mutex);
41 if (!error_message_buffer) { 41 if (!error_message_buffer) {
42 error_message_buffer = 42 error_message_buffer =
43 (char*)MmapOrDieQuietly(kErrorMessageBufferSize, __func__); 43 (char*)MmapOrDieQuietly(kErrorMessageBufferSize, __func__);
@@ -155,10 +155,10 @@ class ScopedInErrorReport {
155 DumpProcessMap(); 155 DumpProcessMap();
156 156
157 // Copy the message buffer so that we could start logging without holding a 157 // Copy the message buffer so that we could start logging without holding a
158 // lock that gets aquired during printing. 158 // lock that gets acquired during printing.
159 InternalMmapVector<char> buffer_copy(kErrorMessageBufferSize); 159 InternalMmapVector<char> buffer_copy(kErrorMessageBufferSize);
160 { 160 {
161 BlockingMutexLock l(&error_message_buf_mutex); 161 Lock l(&error_message_buf_mutex);
162 internal_memcpy(buffer_copy.data(), 162 internal_memcpy(buffer_copy.data(),
163 error_message_buffer, kErrorMessageBufferSize); 163 error_message_buffer, kErrorMessageBufferSize);
164 // Clear error_message_buffer so that if we find other errors 164 // Clear error_message_buffer so that if we find other errors
@@ -490,7 +490,7 @@ void __asan_report_error(uptr pc, uptr bp, uptr sp, uptr addr, int is_write,
490} 490}
491 491
492void NOINLINE __asan_set_error_report_callback(void (*callback)(const char*)) { 492void NOINLINE __asan_set_error_report_callback(void (*callback)(const char*)) {
493 BlockingMutexLock l(&error_message_buf_mutex); 493 Lock l(&error_message_buf_mutex);
494 error_report_callback = callback; 494 error_report_callback = callback;
495} 495}
496 496
diff --git a/libsanitizer/asan/asan_rtl.cpp b/libsanitizer/asan/asan_rtl.cpp
index e06a1113f4e..bfaa3bc2702 100644
--- a/libsanitizer/asan/asan_rtl.cpp
+++ b/libsanitizer/asan/asan_rtl.cpp
@@ -82,6 +82,17 @@ void ShowStatsAndAbort() {
82 Die(); 82 Die();
83} 83}
84 84
85NOINLINE
86static void ReportGenericErrorWrapper(uptr addr, bool is_write, int size,
87 int exp_arg, bool fatal) {
88 if (__asan_test_only_reported_buggy_pointer) {
89 *__asan_test_only_reported_buggy_pointer = addr;
90 } else {
91 GET_CALLER_PC_BP_SP;
92 ReportGenericError(pc, bp, sp, addr, is_write, size, exp_arg, fatal);
93 }
94}
95
85// --------------- LowLevelAllocateCallbac ---------- {{{1 96// --------------- LowLevelAllocateCallbac ---------- {{{1
86static void OnLowLevelAllocate(uptr ptr, uptr size) { 97static void OnLowLevelAllocate(uptr ptr, uptr size) {
87 PoisonShadow(ptr, size, kAsanInternalHeapMagic); 98 PoisonShadow(ptr, size, kAsanInternalHeapMagic);
@@ -145,12 +156,7 @@ ASAN_REPORT_ERROR_N(store, true)
145 if (UNLIKELY(size >= SHADOW_GRANULARITY || \ 156 if (UNLIKELY(size >= SHADOW_GRANULARITY || \
146 ((s8)((addr & (SHADOW_GRANULARITY - 1)) + size - 1)) >= \ 157 ((s8)((addr & (SHADOW_GRANULARITY - 1)) + size - 1)) >= \
147 (s8)s)) { \ 158 (s8)s)) { \
148 if (__asan_test_only_reported_buggy_pointer) { \ 159 ReportGenericErrorWrapper(addr, is_write, size, exp_arg, fatal); \
149 *__asan_test_only_reported_buggy_pointer = addr; \
150 } else { \
151 GET_CALLER_PC_BP_SP; \
152 ReportGenericError(pc, bp, sp, addr, is_write, size, exp_arg, fatal); \
153 } \
154 } \ 160 } \
155 } 161 }
156 162
diff --git a/libsanitizer/asan/asan_stats.cpp b/libsanitizer/asan/asan_stats.cpp
index 00ded8f5ef5..41827610833 100644
--- a/libsanitizer/asan/asan_stats.cpp
+++ b/libsanitizer/asan/asan_stats.cpp
@@ -62,11 +62,11 @@ void AsanStats::MergeFrom(const AsanStats *stats) {
62 dst_ptr[i] += src_ptr[i]; 62 dst_ptr[i] += src_ptr[i];
63} 63}
64 64
65static BlockingMutex print_lock(LINKER_INITIALIZED); 65static Mutex print_lock;
66 66
67static AsanStats unknown_thread_stats(LINKER_INITIALIZED); 67static AsanStats unknown_thread_stats(LINKER_INITIALIZED);
68static AsanStats dead_threads_stats(LINKER_INITIALIZED); 68static AsanStats dead_threads_stats(LINKER_INITIALIZED);
69static BlockingMutex dead_threads_stats_lock(LINKER_INITIALIZED); 69static Mutex dead_threads_stats_lock;
70// Required for malloc_zone_statistics() on OS X. This can't be stored in 70// Required for malloc_zone_statistics() on OS X. This can't be stored in
71// per-thread AsanStats. 71// per-thread AsanStats.
72static uptr max_malloced_memory; 72static uptr max_malloced_memory;
@@ -87,7 +87,7 @@ static void GetAccumulatedStats(AsanStats *stats) {
87 } 87 }
88 stats->MergeFrom(&unknown_thread_stats); 88 stats->MergeFrom(&unknown_thread_stats);
89 { 89 {
90 BlockingMutexLock lock(&dead_threads_stats_lock); 90 Lock lock(&dead_threads_stats_lock);
91 stats->MergeFrom(&dead_threads_stats); 91 stats->MergeFrom(&dead_threads_stats);
92 } 92 }
93 // This is not very accurate: we may miss allocation peaks that happen 93 // This is not very accurate: we may miss allocation peaks that happen
@@ -99,7 +99,7 @@ static void GetAccumulatedStats(AsanStats *stats) {
99} 99}
100 100
101void FlushToDeadThreadStats(AsanStats *stats) { 101void FlushToDeadThreadStats(AsanStats *stats) {
102 BlockingMutexLock lock(&dead_threads_stats_lock); 102 Lock lock(&dead_threads_stats_lock);
103 dead_threads_stats.MergeFrom(stats); 103 dead_threads_stats.MergeFrom(stats);
104 stats->Clear(); 104 stats->Clear();
105} 105}
@@ -122,7 +122,7 @@ static void PrintAccumulatedStats() {
122 AsanStats stats; 122 AsanStats stats;
123 GetAccumulatedStats(&stats); 123 GetAccumulatedStats(&stats);
124 // Use lock to keep reports from mixing up. 124 // Use lock to keep reports from mixing up.
125 BlockingMutexLock lock(&print_lock); 125 Lock lock(&print_lock);
126 stats.Print(); 126 stats.Print();
127 StackDepotStats *stack_depot_stats = StackDepotGetStats(); 127 StackDepotStats *stack_depot_stats = StackDepotGetStats();
128 Printf("Stats: StackDepot: %zd ids; %zdM allocated\n", 128 Printf("Stats: StackDepot: %zd ids; %zdM allocated\n",
diff --git a/libsanitizer/asan/asan_thread.cpp b/libsanitizer/asan/asan_thread.cpp
index 35d4467e7b5..d25e8ee4f45 100644
--- a/libsanitizer/asan/asan_thread.cpp
+++ b/libsanitizer/asan/asan_thread.cpp
@@ -43,11 +43,11 @@ void AsanThreadContext::OnFinished() {
43static ALIGNED(16) char thread_registry_placeholder[sizeof(ThreadRegistry)]; 43static ALIGNED(16) char thread_registry_placeholder[sizeof(ThreadRegistry)];
44static ThreadRegistry *asan_thread_registry; 44static ThreadRegistry *asan_thread_registry;
45 45
46static BlockingMutex mu_for_thread_context(LINKER_INITIALIZED); 46static Mutex mu_for_thread_context;
47static LowLevelAllocator allocator_for_thread_context; 47static LowLevelAllocator allocator_for_thread_context;
48 48
49static ThreadContextBase *GetAsanThreadContext(u32 tid) { 49static ThreadContextBase *GetAsanThreadContext(u32 tid) {
50 BlockingMutexLock lock(&mu_for_thread_context); 50 Lock lock(&mu_for_thread_context);
51 return new(allocator_for_thread_context) AsanThreadContext(tid); 51 return new(allocator_for_thread_context) AsanThreadContext(tid);
52} 52}
53 53
diff --git a/libsanitizer/hwasan/Makefile.am b/libsanitizer/hwasan/Makefile.am
index 5e3a0f1b0a1..cfc1bfe8f01 100644
--- a/libsanitizer/hwasan/Makefile.am
+++ b/libsanitizer/hwasan/Makefile.am
@@ -28,7 +28,8 @@ hwasan_files = \
28 hwasan_new_delete.cpp \ 28 hwasan_new_delete.cpp \
29 hwasan_poisoning.cpp \ 29 hwasan_poisoning.cpp \
30 hwasan_report.cpp \ 30 hwasan_report.cpp \
31 hwasan_setjmp.S \ 31 hwasan_setjmp_aarch64.S \
32 hwasan_setjmp_x86_64.S \
32 hwasan_tag_mismatch_aarch64.S \ 33 hwasan_tag_mismatch_aarch64.S \
33 hwasan_thread.cpp \ 34 hwasan_thread.cpp \
34 hwasan_thread_list.cpp \ 35 hwasan_thread_list.cpp \
diff --git a/libsanitizer/hwasan/Makefile.in b/libsanitizer/hwasan/Makefile.in
index 22c5266a120..f63670b50d1 100644
--- a/libsanitizer/hwasan/Makefile.in
+++ b/libsanitizer/hwasan/Makefile.in
@@ -151,9 +151,9 @@ am__objects_1 = hwasan_allocation_functions.lo hwasan_allocator.lo \
151 hwasan_fuchsia.lo hwasan_globals.lo hwasan_interceptors.lo \ 151 hwasan_fuchsia.lo hwasan_globals.lo hwasan_interceptors.lo \
152 hwasan_interceptors_vfork.lo hwasan_linux.lo \ 152 hwasan_interceptors_vfork.lo hwasan_linux.lo \
153 hwasan_memintrinsics.lo hwasan_new_delete.lo \ 153 hwasan_memintrinsics.lo hwasan_new_delete.lo \
154 hwasan_poisoning.lo hwasan_report.lo hwasan_setjmp.lo \ 154 hwasan_poisoning.lo hwasan_report.lo hwasan_setjmp_aarch64.lo \
155 hwasan_tag_mismatch_aarch64.lo hwasan_thread.lo \ 155 hwasan_setjmp_x86_64.lo hwasan_tag_mismatch_aarch64.lo \
156 hwasan_thread_list.lo hwasan_type_test.lo 156 hwasan_thread.lo hwasan_thread_list.lo hwasan_type_test.lo
157am_libhwasan_la_OBJECTS = $(am__objects_1) 157am_libhwasan_la_OBJECTS = $(am__objects_1)
158libhwasan_la_OBJECTS = $(am_libhwasan_la_OBJECTS) 158libhwasan_la_OBJECTS = $(am_libhwasan_la_OBJECTS)
159AM_V_lt = $(am__v_lt_@AM_V@) 159AM_V_lt = $(am__v_lt_@AM_V@)
@@ -427,7 +427,8 @@ hwasan_files = \
427 hwasan_new_delete.cpp \ 427 hwasan_new_delete.cpp \
428 hwasan_poisoning.cpp \ 428 hwasan_poisoning.cpp \
429 hwasan_report.cpp \ 429 hwasan_report.cpp \
430 hwasan_setjmp.S \ 430 hwasan_setjmp_aarch64.S \
431 hwasan_setjmp_x86_64.S \
431 hwasan_tag_mismatch_aarch64.S \ 432 hwasan_tag_mismatch_aarch64.S \
432 hwasan_thread.cpp \ 433 hwasan_thread.cpp \
433 hwasan_thread_list.cpp \ 434 hwasan_thread_list.cpp \
@@ -570,7 +571,8 @@ distclean-compile:
570@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_new_delete.Plo@am__quote@ 571@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_new_delete.Plo@am__quote@
571@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_poisoning.Plo@am__quote@ 572@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_poisoning.Plo@am__quote@
572@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_report.Plo@am__quote@ 573@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_report.Plo@am__quote@
573@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_setjmp.Plo@am__quote@ 574@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_setjmp_aarch64.Plo@am__quote@
575@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_setjmp_x86_64.Plo@am__quote@
574@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_tag_mismatch_aarch64.Plo@am__quote@ 576@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_tag_mismatch_aarch64.Plo@am__quote@
575@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_thread.Plo@am__quote@ 577@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_thread.Plo@am__quote@
576@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_thread_list.Plo@am__quote@ 578@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_thread_list.Plo@am__quote@
diff --git a/libsanitizer/hwasan/hwasan.cpp b/libsanitizer/hwasan/hwasan.cpp
index cbe0dee66dc..46541902212 100644
--- a/libsanitizer/hwasan/hwasan.cpp
+++ b/libsanitizer/hwasan/hwasan.cpp
@@ -319,7 +319,7 @@ void __hwasan_init_static() {
319 InitializeSingleGlobal(global); 319 InitializeSingleGlobal(global);
320} 320}
321 321
322void __hwasan_init() { 322__attribute__((constructor(0))) void __hwasan_init() {
323 CHECK(!hwasan_init_is_running); 323 CHECK(!hwasan_init_is_running);
324 if (hwasan_inited) return; 324 if (hwasan_inited) return;
325 hwasan_init_is_running = 1; 325 hwasan_init_is_running = 1;
@@ -360,6 +360,7 @@ void __hwasan_init() {
360 HwasanTSDThreadInit(); 360 HwasanTSDThreadInit();
361 361
362 HwasanAllocatorInit(); 362 HwasanAllocatorInit();
363 HwasanInstallAtForkHandler();
363 364
364#if HWASAN_CONTAINS_UBSAN 365#if HWASAN_CONTAINS_UBSAN
365 __ubsan::InitAsPlugin(); 366 __ubsan::InitAsPlugin();
diff --git a/libsanitizer/hwasan/hwasan.h b/libsanitizer/hwasan/hwasan.h
index 7338b696ad3..371c43f3cbd 100644
--- a/libsanitizer/hwasan/hwasan.h
+++ b/libsanitizer/hwasan/hwasan.h
@@ -107,6 +107,8 @@ void InitThreads();
107void InitializeInterceptors(); 107void InitializeInterceptors();
108 108
109void HwasanAllocatorInit(); 109void HwasanAllocatorInit();
110void HwasanAllocatorLock();
111void HwasanAllocatorUnlock();
110 112
111void *hwasan_malloc(uptr size, StackTrace *stack); 113void *hwasan_malloc(uptr size, StackTrace *stack);
112void *hwasan_calloc(uptr nmemb, uptr size, StackTrace *stack); 114void *hwasan_calloc(uptr nmemb, uptr size, StackTrace *stack);
@@ -140,6 +142,8 @@ void HwasanAtExit();
140 142
141void HwasanOnDeadlySignal(int signo, void *info, void *context); 143void HwasanOnDeadlySignal(int signo, void *info, void *context);
142 144
145void HwasanInstallAtForkHandler();
146
143void UpdateMemoryUsage(); 147void UpdateMemoryUsage();
144 148
145void AppendToErrorMessageBuffer(const char *buffer); 149void AppendToErrorMessageBuffer(const char *buffer);
@@ -183,25 +187,34 @@ void HwasanTagMismatch(uptr addr, uptr access_info, uptr *registers_frame,
183 RunFreeHooks(ptr); \ 187 RunFreeHooks(ptr); \
184 } while (false) 188 } while (false)
185 189
186#if HWASAN_WITH_INTERCEPTORS && defined(__aarch64__) 190#if HWASAN_WITH_INTERCEPTORS
187// For both bionic and glibc __sigset_t is an unsigned long. 191// For both bionic and glibc __sigset_t is an unsigned long.
188typedef unsigned long __hw_sigset_t; 192typedef unsigned long __hw_sigset_t;
189// Setjmp and longjmp implementations are platform specific, and hence the 193// Setjmp and longjmp implementations are platform specific, and hence the
190// interception code is platform specific too. As yet we've only implemented 194// interception code is platform specific too.
191// the interception for AArch64. 195# if defined(__aarch64__)
192typedef unsigned long long __hw_register_buf[22]; 196constexpr size_t kHwRegisterBufSize = 22;
197# elif defined(__x86_64__)
198constexpr size_t kHwRegisterBufSize = 8;
199# endif
200typedef unsigned long long __hw_register_buf[kHwRegisterBufSize];
193struct __hw_jmp_buf_struct { 201struct __hw_jmp_buf_struct {
194 // NOTE: The machine-dependent definition of `__sigsetjmp' 202 // NOTE: The machine-dependent definition of `__sigsetjmp'
195 // assume that a `__hw_jmp_buf' begins with a `__hw_register_buf' and that 203 // assume that a `__hw_jmp_buf' begins with a `__hw_register_buf' and that
196 // `__mask_was_saved' follows it. Do not move these members or add others 204 // `__mask_was_saved' follows it. Do not move these members or add others
197 // before it. 205 // before it.
206 //
207 // We add a __magic field to our struct to catch cases where libc's setjmp
208 // populated the jmp_buf instead of our interceptor.
198 __hw_register_buf __jmpbuf; // Calling environment. 209 __hw_register_buf __jmpbuf; // Calling environment.
199 int __mask_was_saved; // Saved the signal mask? 210 unsigned __mask_was_saved : 1; // Saved the signal mask?
211 unsigned __magic : 31; // Used to distinguish __hw_jmp_buf from jmp_buf.
200 __hw_sigset_t __saved_mask; // Saved signal mask. 212 __hw_sigset_t __saved_mask; // Saved signal mask.
201}; 213};
202typedef struct __hw_jmp_buf_struct __hw_jmp_buf[1]; 214typedef struct __hw_jmp_buf_struct __hw_jmp_buf[1];
203typedef struct __hw_jmp_buf_struct __hw_sigjmp_buf[1]; 215typedef struct __hw_jmp_buf_struct __hw_sigjmp_buf[1];
204#endif // HWASAN_WITH_INTERCEPTORS && __aarch64__ 216constexpr unsigned kHwJmpBufMagic = 0x248ACE77;
217#endif // HWASAN_WITH_INTERCEPTORS
205 218
206#define ENSURE_HWASAN_INITED() \ 219#define ENSURE_HWASAN_INITED() \
207 do { \ 220 do { \
diff --git a/libsanitizer/hwasan/hwasan_allocation_functions.cpp b/libsanitizer/hwasan/hwasan_allocation_functions.cpp
index 6c2a6077866..850daedd0b0 100644
--- a/libsanitizer/hwasan/hwasan_allocation_functions.cpp
+++ b/libsanitizer/hwasan/hwasan_allocation_functions.cpp
@@ -17,6 +17,8 @@
17#include "sanitizer_common/sanitizer_allocator_interface.h" 17#include "sanitizer_common/sanitizer_allocator_interface.h"
18#include "sanitizer_common/sanitizer_tls_get_addr.h" 18#include "sanitizer_common/sanitizer_tls_get_addr.h"
19 19
20#if !SANITIZER_FUCHSIA
21
20using namespace __hwasan; 22using namespace __hwasan;
21 23
22static uptr allocated_for_dlsym; 24static uptr allocated_for_dlsym;
@@ -36,6 +38,9 @@ static void *AllocateFromLocalPool(uptr size_in_bytes) {
36 return mem; 38 return mem;
37} 39}
38 40
41extern "C" {
42
43SANITIZER_INTERFACE_ATTRIBUTE
39int __sanitizer_posix_memalign(void **memptr, uptr alignment, uptr size) { 44int __sanitizer_posix_memalign(void **memptr, uptr alignment, uptr size) {
40 GET_MALLOC_STACK_TRACE; 45 GET_MALLOC_STACK_TRACE;
41 CHECK_NE(memptr, 0); 46 CHECK_NE(memptr, 0);
@@ -43,16 +48,19 @@ int __sanitizer_posix_memalign(void **memptr, uptr alignment, uptr size) {
43 return res; 48 return res;
44} 49}
45 50
51SANITIZER_INTERFACE_ATTRIBUTE
46void *__sanitizer_memalign(uptr alignment, uptr size) { 52void *__sanitizer_memalign(uptr alignment, uptr size) {
47 GET_MALLOC_STACK_TRACE; 53 GET_MALLOC_STACK_TRACE;
48 return hwasan_memalign(alignment, size, &stack); 54 return hwasan_memalign(alignment, size, &stack);
49} 55}
50 56
57SANITIZER_INTERFACE_ATTRIBUTE
51void *__sanitizer_aligned_alloc(uptr alignment, uptr size) { 58void *__sanitizer_aligned_alloc(uptr alignment, uptr size) {
52 GET_MALLOC_STACK_TRACE; 59 GET_MALLOC_STACK_TRACE;
53 return hwasan_aligned_alloc(alignment, size, &stack); 60 return hwasan_aligned_alloc(alignment, size, &stack);
54} 61}
55 62
63SANITIZER_INTERFACE_ATTRIBUTE
56void *__sanitizer___libc_memalign(uptr alignment, uptr size) { 64void *__sanitizer___libc_memalign(uptr alignment, uptr size) {
57 GET_MALLOC_STACK_TRACE; 65 GET_MALLOC_STACK_TRACE;
58 void *ptr = hwasan_memalign(alignment, size, &stack); 66 void *ptr = hwasan_memalign(alignment, size, &stack);
@@ -61,16 +69,19 @@ void *__sanitizer___libc_memalign(uptr alignment, uptr size) {
61 return ptr; 69 return ptr;
62} 70}
63 71
72SANITIZER_INTERFACE_ATTRIBUTE
64void *__sanitizer_valloc(uptr size) { 73void *__sanitizer_valloc(uptr size) {
65 GET_MALLOC_STACK_TRACE; 74 GET_MALLOC_STACK_TRACE;
66 return hwasan_valloc(size, &stack); 75 return hwasan_valloc(size, &stack);
67} 76}
68 77
78SANITIZER_INTERFACE_ATTRIBUTE
69void *__sanitizer_pvalloc(uptr size) { 79void *__sanitizer_pvalloc(uptr size) {
70 GET_MALLOC_STACK_TRACE; 80 GET_MALLOC_STACK_TRACE;
71 return hwasan_pvalloc(size, &stack); 81 return hwasan_pvalloc(size, &stack);
72} 82}
73 83
84SANITIZER_INTERFACE_ATTRIBUTE
74void __sanitizer_free(void *ptr) { 85void __sanitizer_free(void *ptr) {
75 GET_MALLOC_STACK_TRACE; 86 GET_MALLOC_STACK_TRACE;
76 if (!ptr || UNLIKELY(IsInDlsymAllocPool(ptr))) 87 if (!ptr || UNLIKELY(IsInDlsymAllocPool(ptr)))
@@ -78,6 +89,7 @@ void __sanitizer_free(void *ptr) {
78 hwasan_free(ptr, &stack); 89 hwasan_free(ptr, &stack);
79} 90}
80 91
92SANITIZER_INTERFACE_ATTRIBUTE
81void __sanitizer_cfree(void *ptr) { 93void __sanitizer_cfree(void *ptr) {
82 GET_MALLOC_STACK_TRACE; 94 GET_MALLOC_STACK_TRACE;
83 if (!ptr || UNLIKELY(IsInDlsymAllocPool(ptr))) 95 if (!ptr || UNLIKELY(IsInDlsymAllocPool(ptr)))
@@ -85,22 +97,27 @@ void __sanitizer_cfree(void *ptr) {
85 hwasan_free(ptr, &stack); 97 hwasan_free(ptr, &stack);
86} 98}
87 99
100SANITIZER_INTERFACE_ATTRIBUTE
88uptr __sanitizer_malloc_usable_size(const void *ptr) { 101uptr __sanitizer_malloc_usable_size(const void *ptr) {
89 return __sanitizer_get_allocated_size(ptr); 102 return __sanitizer_get_allocated_size(ptr);
90} 103}
91 104
105SANITIZER_INTERFACE_ATTRIBUTE
92struct __sanitizer_struct_mallinfo __sanitizer_mallinfo() { 106struct __sanitizer_struct_mallinfo __sanitizer_mallinfo() {
93 __sanitizer_struct_mallinfo sret; 107 __sanitizer_struct_mallinfo sret;
94 internal_memset(&sret, 0, sizeof(sret)); 108 internal_memset(&sret, 0, sizeof(sret));
95 return sret; 109 return sret;
96} 110}
97 111
112SANITIZER_INTERFACE_ATTRIBUTE
98int __sanitizer_mallopt(int cmd, int value) { return 0; } 113int __sanitizer_mallopt(int cmd, int value) { return 0; }
99 114
115SANITIZER_INTERFACE_ATTRIBUTE
100void __sanitizer_malloc_stats(void) { 116void __sanitizer_malloc_stats(void) {
101 // FIXME: implement, but don't call REAL(malloc_stats)! 117 // FIXME: implement, but don't call REAL(malloc_stats)!
102} 118}
103 119
120SANITIZER_INTERFACE_ATTRIBUTE
104void *__sanitizer_calloc(uptr nmemb, uptr size) { 121void *__sanitizer_calloc(uptr nmemb, uptr size) {
105 GET_MALLOC_STACK_TRACE; 122 GET_MALLOC_STACK_TRACE;
106 if (UNLIKELY(!hwasan_inited)) 123 if (UNLIKELY(!hwasan_inited))
@@ -109,6 +126,7 @@ void *__sanitizer_calloc(uptr nmemb, uptr size) {
109 return hwasan_calloc(nmemb, size, &stack); 126 return hwasan_calloc(nmemb, size, &stack);
110} 127}
111 128
129SANITIZER_INTERFACE_ATTRIBUTE
112void *__sanitizer_realloc(void *ptr, uptr size) { 130void *__sanitizer_realloc(void *ptr, uptr size) {
113 GET_MALLOC_STACK_TRACE; 131 GET_MALLOC_STACK_TRACE;
114 if (UNLIKELY(IsInDlsymAllocPool(ptr))) { 132 if (UNLIKELY(IsInDlsymAllocPool(ptr))) {
@@ -127,11 +145,13 @@ void *__sanitizer_realloc(void *ptr, uptr size) {
127 return hwasan_realloc(ptr, size, &stack); 145 return hwasan_realloc(ptr, size, &stack);
128} 146}
129 147
148SANITIZER_INTERFACE_ATTRIBUTE
130void *__sanitizer_reallocarray(void *ptr, uptr nmemb, uptr size) { 149void *__sanitizer_reallocarray(void *ptr, uptr nmemb, uptr size) {
131 GET_MALLOC_STACK_TRACE; 150 GET_MALLOC_STACK_TRACE;
132 return hwasan_reallocarray(ptr, nmemb, size, &stack); 151 return hwasan_reallocarray(ptr, nmemb, size, &stack);
133} 152}
134 153
154SANITIZER_INTERFACE_ATTRIBUTE
135void *__sanitizer_malloc(uptr size) { 155void *__sanitizer_malloc(uptr size) {
136 GET_MALLOC_STACK_TRACE; 156 GET_MALLOC_STACK_TRACE;
137 if (UNLIKELY(!hwasan_init_is_running)) 157 if (UNLIKELY(!hwasan_init_is_running))
@@ -142,6 +162,8 @@ void *__sanitizer_malloc(uptr size) {
142 return hwasan_malloc(size, &stack); 162 return hwasan_malloc(size, &stack);
143} 163}
144 164
165} // extern "C"
166
145#if HWASAN_WITH_INTERCEPTORS 167#if HWASAN_WITH_INTERCEPTORS
146# define INTERCEPTOR_ALIAS(RET, FN, ARGS...) \ 168# define INTERCEPTOR_ALIAS(RET, FN, ARGS...) \
147 extern "C" SANITIZER_INTERFACE_ATTRIBUTE RET WRAP(FN)(ARGS) \ 169 extern "C" SANITIZER_INTERFACE_ATTRIBUTE RET WRAP(FN)(ARGS) \
@@ -170,3 +192,5 @@ INTERCEPTOR_ALIAS(int, mallopt, int cmd, int value);
170INTERCEPTOR_ALIAS(void, malloc_stats, void); 192INTERCEPTOR_ALIAS(void, malloc_stats, void);
171# endif 193# endif
172#endif // #if HWASAN_WITH_INTERCEPTORS 194#endif // #if HWASAN_WITH_INTERCEPTORS
195
196#endif // SANITIZER_FUCHSIA
diff --git a/libsanitizer/hwasan/hwasan_allocator.cpp b/libsanitizer/hwasan/hwasan_allocator.cpp
index ef6d4d6c767..9e1729964e2 100644
--- a/libsanitizer/hwasan/hwasan_allocator.cpp
+++ b/libsanitizer/hwasan/hwasan_allocator.cpp
@@ -107,6 +107,10 @@ void HwasanAllocatorInit() {
107 tail_magic[i] = GetCurrentThread()->GenerateRandomTag(); 107 tail_magic[i] = GetCurrentThread()->GenerateRandomTag();
108} 108}
109 109
110void HwasanAllocatorLock() { allocator.ForceLock(); }
111
112void HwasanAllocatorUnlock() { allocator.ForceUnlock(); }
113
110void AllocatorSwallowThreadLocalCache(AllocatorCache *cache) { 114void AllocatorSwallowThreadLocalCache(AllocatorCache *cache) {
111 allocator.SwallowCache(cache); 115 allocator.SwallowCache(cache);
112} 116}
@@ -158,8 +162,11 @@ static void *HwasanAllocate(StackTrace *stack, uptr orig_size, uptr alignment,
158 internal_memset(allocated, flags()->malloc_fill_byte, fill_size); 162 internal_memset(allocated, flags()->malloc_fill_byte, fill_size);
159 } 163 }
160 if (size != orig_size) { 164 if (size != orig_size) {
161 internal_memcpy(reinterpret_cast<u8 *>(allocated) + orig_size, tail_magic, 165 u8 *tail = reinterpret_cast<u8 *>(allocated) + orig_size;
162 size - orig_size - 1); 166 uptr tail_length = size - orig_size;
167 internal_memcpy(tail, tail_magic, tail_length - 1);
168 // Short granule is excluded from magic tail, so we explicitly untag.
169 tail[tail_length - 1] = 0;
163 } 170 }
164 171
165 void *user_ptr = allocated; 172 void *user_ptr = allocated;
@@ -201,21 +208,37 @@ static bool PointerAndMemoryTagsMatch(void *tagged_ptr) {
201 return PossiblyShortTagMatches(mem_tag, tagged_uptr, 1); 208 return PossiblyShortTagMatches(mem_tag, tagged_uptr, 1);
202} 209}
203 210
211static bool CheckInvalidFree(StackTrace *stack, void *untagged_ptr,
212 void *tagged_ptr) {
213 // This function can return true if halt_on_error is false.
214 if (!MemIsApp(reinterpret_cast<uptr>(untagged_ptr)) ||
215 !PointerAndMemoryTagsMatch(tagged_ptr)) {
216 ReportInvalidFree(stack, reinterpret_cast<uptr>(tagged_ptr));
217 return true;
218 }
219 return false;
220}
221
204static void HwasanDeallocate(StackTrace *stack, void *tagged_ptr) { 222static void HwasanDeallocate(StackTrace *stack, void *tagged_ptr) {
205 CHECK(tagged_ptr); 223 CHECK(tagged_ptr);
206 HWASAN_FREE_HOOK(tagged_ptr); 224 HWASAN_FREE_HOOK(tagged_ptr);
207 225
208 if (!PointerAndMemoryTagsMatch(tagged_ptr)) 226 bool in_taggable_region =
209 ReportInvalidFree(stack, reinterpret_cast<uptr>(tagged_ptr)); 227 InTaggableRegion(reinterpret_cast<uptr>(tagged_ptr));
228 void *untagged_ptr = in_taggable_region ? UntagPtr(tagged_ptr) : tagged_ptr;
229
230 if (CheckInvalidFree(stack, untagged_ptr, tagged_ptr))
231 return;
210 232
211 void *untagged_ptr = InTaggableRegion(reinterpret_cast<uptr>(tagged_ptr))
212 ? UntagPtr(tagged_ptr)
213 : tagged_ptr;
214 void *aligned_ptr = reinterpret_cast<void *>( 233 void *aligned_ptr = reinterpret_cast<void *>(
215 RoundDownTo(reinterpret_cast<uptr>(untagged_ptr), kShadowAlignment)); 234 RoundDownTo(reinterpret_cast<uptr>(untagged_ptr), kShadowAlignment));
216 tag_t pointer_tag = GetTagFromPointer(reinterpret_cast<uptr>(tagged_ptr)); 235 tag_t pointer_tag = GetTagFromPointer(reinterpret_cast<uptr>(tagged_ptr));
217 Metadata *meta = 236 Metadata *meta =
218 reinterpret_cast<Metadata *>(allocator.GetMetaData(aligned_ptr)); 237 reinterpret_cast<Metadata *>(allocator.GetMetaData(aligned_ptr));
238 if (!meta) {
239 ReportInvalidFree(stack, reinterpret_cast<uptr>(tagged_ptr));
240 return;
241 }
219 uptr orig_size = meta->get_requested_size(); 242 uptr orig_size = meta->get_requested_size();
220 u32 free_context_id = StackDepotPut(*stack); 243 u32 free_context_id = StackDepotPut(*stack);
221 u32 alloc_context_id = meta->alloc_context_id; 244 u32 alloc_context_id = meta->alloc_context_id;
@@ -228,7 +251,11 @@ static void HwasanDeallocate(StackTrace *stack, void *tagged_ptr) {
228 CHECK_LT(tail_size, kShadowAlignment); 251 CHECK_LT(tail_size, kShadowAlignment);
229 void *tail_beg = reinterpret_cast<void *>( 252 void *tail_beg = reinterpret_cast<void *>(
230 reinterpret_cast<uptr>(aligned_ptr) + orig_size); 253 reinterpret_cast<uptr>(aligned_ptr) + orig_size);
231 if (tail_size && internal_memcmp(tail_beg, tail_magic, tail_size)) 254 tag_t short_granule_memtag = *(reinterpret_cast<tag_t *>(
255 reinterpret_cast<uptr>(tail_beg) + tail_size));
256 if (tail_size &&
257 (internal_memcmp(tail_beg, tail_magic, tail_size) ||
258 (in_taggable_region && pointer_tag != short_granule_memtag)))
232 ReportTailOverwritten(stack, reinterpret_cast<uptr>(tagged_ptr), 259 ReportTailOverwritten(stack, reinterpret_cast<uptr>(tagged_ptr),
233 orig_size, tail_magic); 260 orig_size, tail_magic);
234 } 261 }
@@ -243,8 +270,7 @@ static void HwasanDeallocate(StackTrace *stack, void *tagged_ptr) {
243 Min(TaggedSize(orig_size), (uptr)flags()->max_free_fill_size); 270 Min(TaggedSize(orig_size), (uptr)flags()->max_free_fill_size);
244 internal_memset(aligned_ptr, flags()->free_fill_byte, fill_size); 271 internal_memset(aligned_ptr, flags()->free_fill_byte, fill_size);
245 } 272 }
246 if (InTaggableRegion(reinterpret_cast<uptr>(tagged_ptr)) && 273 if (in_taggable_region && flags()->tag_in_free && malloc_bisect(stack, 0) &&
247 flags()->tag_in_free && malloc_bisect(stack, 0) &&
248 atomic_load_relaxed(&hwasan_allocator_tagging_enabled)) { 274 atomic_load_relaxed(&hwasan_allocator_tagging_enabled)) {
249 // Always store full 8-bit tags on free to maximize UAF detection. 275 // Always store full 8-bit tags on free to maximize UAF detection.
250 tag_t tag; 276 tag_t tag;
@@ -278,13 +304,15 @@ static void HwasanDeallocate(StackTrace *stack, void *tagged_ptr) {
278 304
279static void *HwasanReallocate(StackTrace *stack, void *tagged_ptr_old, 305static void *HwasanReallocate(StackTrace *stack, void *tagged_ptr_old,
280 uptr new_size, uptr alignment) { 306 uptr new_size, uptr alignment) {
281 if (!PointerAndMemoryTagsMatch(tagged_ptr_old)) 307 void *untagged_ptr_old =
282 ReportInvalidFree(stack, reinterpret_cast<uptr>(tagged_ptr_old)); 308 InTaggableRegion(reinterpret_cast<uptr>(tagged_ptr_old))
283 309 ? UntagPtr(tagged_ptr_old)
310 : tagged_ptr_old;
311 if (CheckInvalidFree(stack, untagged_ptr_old, tagged_ptr_old))
312 return nullptr;
284 void *tagged_ptr_new = 313 void *tagged_ptr_new =
285 HwasanAllocate(stack, new_size, alignment, false /*zeroise*/); 314 HwasanAllocate(stack, new_size, alignment, false /*zeroise*/);
286 if (tagged_ptr_old && tagged_ptr_new) { 315 if (tagged_ptr_old && tagged_ptr_new) {
287 void *untagged_ptr_old = UntagPtr(tagged_ptr_old);
288 Metadata *meta = 316 Metadata *meta =
289 reinterpret_cast<Metadata *>(allocator.GetMetaData(untagged_ptr_old)); 317 reinterpret_cast<Metadata *>(allocator.GetMetaData(untagged_ptr_old));
290 internal_memcpy( 318 internal_memcpy(
@@ -305,6 +333,8 @@ static void *HwasanCalloc(StackTrace *stack, uptr nmemb, uptr size) {
305} 333}
306 334
307HwasanChunkView FindHeapChunkByAddress(uptr address) { 335HwasanChunkView FindHeapChunkByAddress(uptr address) {
336 if (!allocator.PointerIsMine(reinterpret_cast<void *>(address)))
337 return HwasanChunkView();
308 void *block = allocator.GetBlockBegin(reinterpret_cast<void*>(address)); 338 void *block = allocator.GetBlockBegin(reinterpret_cast<void*>(address));
309 if (!block) 339 if (!block)
310 return HwasanChunkView(); 340 return HwasanChunkView();
diff --git a/libsanitizer/hwasan/hwasan_dynamic_shadow.cpp b/libsanitizer/hwasan/hwasan_dynamic_shadow.cpp
index bde22dfa4bc..7642ba6c0bf 100644
--- a/libsanitizer/hwasan/hwasan_dynamic_shadow.cpp
+++ b/libsanitizer/hwasan/hwasan_dynamic_shadow.cpp
@@ -113,6 +113,15 @@ uptr FindDynamicShadowStart(uptr shadow_size_bytes) {
113} 113}
114 114
115} // namespace __hwasan 115} // namespace __hwasan
116
117#elif SANITIZER_FUCHSIA
118
119namespace __hwasan {
120
121void InitShadowGOT() {}
122
123} // namespace __hwasan
124
116#else 125#else
117namespace __hwasan { 126namespace __hwasan {
118 127
diff --git a/libsanitizer/hwasan/hwasan_fuchsia.cpp b/libsanitizer/hwasan/hwasan_fuchsia.cpp
index e61f6ada72f..f51e148197b 100644
--- a/libsanitizer/hwasan/hwasan_fuchsia.cpp
+++ b/libsanitizer/hwasan/hwasan_fuchsia.cpp
@@ -34,6 +34,15 @@ bool InitShadow() {
34 __sanitizer::InitShadowBounds(); 34 __sanitizer::InitShadowBounds();
35 CHECK_NE(__sanitizer::ShadowBounds.shadow_limit, 0); 35 CHECK_NE(__sanitizer::ShadowBounds.shadow_limit, 0);
36 36
37 // These variables are used by MemIsShadow for asserting we have a correct
38 // shadow address. On Fuchsia, we only have one region of shadow, so the
39 // bounds of Low shadow can be zero while High shadow represents the true
40 // bounds. Note that these are inclusive ranges.
41 kLowShadowStart = 0;
42 kLowShadowEnd = 0;
43 kHighShadowStart = __sanitizer::ShadowBounds.shadow_base;
44 kHighShadowEnd = __sanitizer::ShadowBounds.shadow_limit - 1;
45
37 return true; 46 return true;
38} 47}
39 48
@@ -143,6 +152,14 @@ static void ThreadExitHook(void *hook, thrd_t self) {
143 hwasanThreadList().ReleaseThread(thread); 152 hwasanThreadList().ReleaseThread(thread);
144} 153}
145 154
155uptr TagMemoryAligned(uptr p, uptr size, tag_t tag) {
156 CHECK(IsAligned(p, kShadowAlignment));
157 CHECK(IsAligned(size, kShadowAlignment));
158 __sanitizer_fill_shadow(p, size, tag,
159 common_flags()->clear_shadow_mmap_threshold);
160 return AddTagToPointer(p, tag);
161}
162
146// Not implemented because Fuchsia does not use signal handlers. 163// Not implemented because Fuchsia does not use signal handlers.
147void HwasanOnDeadlySignal(int signo, void *info, void *context) {} 164void HwasanOnDeadlySignal(int signo, void *info, void *context) {}
148 165
@@ -163,6 +180,12 @@ void HwasanTSDThreadInit() {}
163// function is unneeded. 180// function is unneeded.
164void InstallAtExitHandler() {} 181void InstallAtExitHandler() {}
165 182
183void HwasanInstallAtForkHandler() {}
184
185// TODO(fxbug.dev/81499): Once we finalize the tagged pointer ABI in zircon, we should come back
186// here and implement the appropriate check that TBI is enabled.
187void InitializeOsSupport() {}
188
166} // namespace __hwasan 189} // namespace __hwasan
167 190
168extern "C" { 191extern "C" {
diff --git a/libsanitizer/hwasan/hwasan_interceptors.cpp b/libsanitizer/hwasan/hwasan_interceptors.cpp
index 68f8adec077..f96ed880410 100644
--- a/libsanitizer/hwasan/hwasan_interceptors.cpp
+++ b/libsanitizer/hwasan/hwasan_interceptors.cpp
@@ -49,15 +49,14 @@ INTERCEPTOR(int, pthread_create, void *th, void *attr, void *(*callback)(void*),
49 49
50DEFINE_REAL(int, vfork) 50DEFINE_REAL(int, vfork)
51DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(int, vfork) 51DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(int, vfork)
52#endif // HWASAN_WITH_INTERCEPTORS
53 52
54#if HWASAN_WITH_INTERCEPTORS && defined(__aarch64__)
55// Get and/or change the set of blocked signals. 53// Get and/or change the set of blocked signals.
56extern "C" int sigprocmask(int __how, const __hw_sigset_t *__restrict __set, 54extern "C" int sigprocmask(int __how, const __hw_sigset_t *__restrict __set,
57 __hw_sigset_t *__restrict __oset); 55 __hw_sigset_t *__restrict __oset);
58#define SIG_BLOCK 0 56#define SIG_BLOCK 0
59#define SIG_SETMASK 2 57#define SIG_SETMASK 2
60extern "C" int __sigjmp_save(__hw_sigjmp_buf env, int savemask) { 58extern "C" int __sigjmp_save(__hw_sigjmp_buf env, int savemask) {
59 env[0].__magic = kHwJmpBufMagic;
61 env[0].__mask_was_saved = 60 env[0].__mask_was_saved =
62 (savemask && sigprocmask(SIG_BLOCK, (__hw_sigset_t *)0, 61 (savemask && sigprocmask(SIG_BLOCK, (__hw_sigset_t *)0,
63 &env[0].__saved_mask) == 0); 62 &env[0].__saved_mask) == 0);
@@ -66,8 +65,14 @@ extern "C" int __sigjmp_save(__hw_sigjmp_buf env, int savemask) {
66 65
67static void __attribute__((always_inline)) 66static void __attribute__((always_inline))
68InternalLongjmp(__hw_register_buf env, int retval) { 67InternalLongjmp(__hw_register_buf env, int retval) {
68# if defined(__aarch64__)
69 constexpr size_t kSpIndex = 13;
70# elif defined(__x86_64__)
71 constexpr size_t kSpIndex = 6;
72# endif
73
69 // Clear all memory tags on the stack between here and where we're going. 74 // Clear all memory tags on the stack between here and where we're going.
70 unsigned long long stack_pointer = env[13]; 75 unsigned long long stack_pointer = env[kSpIndex];
71 // The stack pointer should never be tagged, so we don't need to clear the 76 // The stack pointer should never be tagged, so we don't need to clear the
72 // tag for this function call. 77 // tag for this function call.
73 __hwasan_handle_longjmp((void *)stack_pointer); 78 __hwasan_handle_longjmp((void *)stack_pointer);
@@ -78,6 +83,7 @@ InternalLongjmp(__hw_register_buf env, int retval) {
78 // Must implement this ourselves, since we don't know the order of registers 83 // Must implement this ourselves, since we don't know the order of registers
79 // in different libc implementations and many implementations mangle the 84 // in different libc implementations and many implementations mangle the
80 // stack pointer so we can't use it without knowing the demangling scheme. 85 // stack pointer so we can't use it without knowing the demangling scheme.
86# if defined(__aarch64__)
81 register long int retval_tmp asm("x1") = retval; 87 register long int retval_tmp asm("x1") = retval;
82 register void *env_address asm("x0") = &env[0]; 88 register void *env_address asm("x0") = &env[0];
83 asm volatile("ldp x19, x20, [%0, #0<<3];" 89 asm volatile("ldp x19, x20, [%0, #0<<3];"
@@ -100,9 +106,36 @@ InternalLongjmp(__hw_register_buf env, int retval) {
100 "br x30;" 106 "br x30;"
101 : "+r"(env_address) 107 : "+r"(env_address)
102 : "r"(retval_tmp)); 108 : "r"(retval_tmp));
109# elif defined(__x86_64__)
110 register long int retval_tmp asm("%rsi") = retval;
111 register void *env_address asm("%rdi") = &env[0];
112 asm volatile(
113 // Restore registers.
114 "mov (0*8)(%0),%%rbx;"
115 "mov (1*8)(%0),%%rbp;"
116 "mov (2*8)(%0),%%r12;"
117 "mov (3*8)(%0),%%r13;"
118 "mov (4*8)(%0),%%r14;"
119 "mov (5*8)(%0),%%r15;"
120 "mov (6*8)(%0),%%rsp;"
121 "mov (7*8)(%0),%%rdx;"
122 // Return 1 if retval is 0.
123 "mov $1,%%rax;"
124 "test %1,%1;"
125 "cmovnz %1,%%rax;"
126 "jmp *%%rdx;" ::"r"(env_address),
127 "r"(retval_tmp));
128# endif
103} 129}
104 130
105INTERCEPTOR(void, siglongjmp, __hw_sigjmp_buf env, int val) { 131INTERCEPTOR(void, siglongjmp, __hw_sigjmp_buf env, int val) {
132 if (env[0].__magic != kHwJmpBufMagic) {
133 Printf(
134 "WARNING: Unexpected bad jmp_buf. Either setjmp was not called or "
135 "there is a bug in HWASan.\n");
136 return REAL(siglongjmp)(env, val);
137 }
138
106 if (env[0].__mask_was_saved) 139 if (env[0].__mask_was_saved)
107 // Restore the saved signal mask. 140 // Restore the saved signal mask.
108 (void)sigprocmask(SIG_SETMASK, &env[0].__saved_mask, 141 (void)sigprocmask(SIG_SETMASK, &env[0].__saved_mask,
@@ -114,32 +147,24 @@ INTERCEPTOR(void, siglongjmp, __hw_sigjmp_buf env, int val) {
114// _setjmp on start_thread. Hence we have to intercept the longjmp on 147// _setjmp on start_thread. Hence we have to intercept the longjmp on
115// pthread_exit so the __hw_jmp_buf order matches. 148// pthread_exit so the __hw_jmp_buf order matches.
116INTERCEPTOR(void, __libc_longjmp, __hw_jmp_buf env, int val) { 149INTERCEPTOR(void, __libc_longjmp, __hw_jmp_buf env, int val) {
150 if (env[0].__magic != kHwJmpBufMagic)
151 return REAL(__libc_longjmp)(env, val);
117 InternalLongjmp(env[0].__jmpbuf, val); 152 InternalLongjmp(env[0].__jmpbuf, val);
118} 153}
119 154
120INTERCEPTOR(void, longjmp, __hw_jmp_buf env, int val) { 155INTERCEPTOR(void, longjmp, __hw_jmp_buf env, int val) {
156 if (env[0].__magic != kHwJmpBufMagic) {
157 Printf(
158 "WARNING: Unexpected bad jmp_buf. Either setjmp was not called or "
159 "there is a bug in HWASan.\n");
160 return REAL(longjmp)(env, val);
161 }
121 InternalLongjmp(env[0].__jmpbuf, val); 162 InternalLongjmp(env[0].__jmpbuf, val);
122} 163}
123#undef SIG_BLOCK 164#undef SIG_BLOCK
124#undef SIG_SETMASK 165#undef SIG_SETMASK
125 166
126#endif // HWASAN_WITH_INTERCEPTORS && __aarch64__ 167# endif // HWASAN_WITH_INTERCEPTORS
127
128static void BeforeFork() {
129 StackDepotLockAll();
130}
131
132static void AfterFork() {
133 StackDepotUnlockAll();
134}
135
136INTERCEPTOR(int, fork, void) {
137 ENSURE_HWASAN_INITED();
138 BeforeFork();
139 int pid = REAL(fork)();
140 AfterFork();
141 return pid;
142}
143 168
144namespace __hwasan { 169namespace __hwasan {
145 170
@@ -156,10 +181,11 @@ void InitializeInterceptors() {
156 static int inited = 0; 181 static int inited = 0;
157 CHECK_EQ(inited, 0); 182 CHECK_EQ(inited, 0);
158 183
159 INTERCEPT_FUNCTION(fork);
160
161#if HWASAN_WITH_INTERCEPTORS 184#if HWASAN_WITH_INTERCEPTORS
162#if defined(__linux__) 185#if defined(__linux__)
186 INTERCEPT_FUNCTION(__libc_longjmp);
187 INTERCEPT_FUNCTION(longjmp);
188 INTERCEPT_FUNCTION(siglongjmp);
163 INTERCEPT_FUNCTION(vfork); 189 INTERCEPT_FUNCTION(vfork);
164#endif // __linux__ 190#endif // __linux__
165 INTERCEPT_FUNCTION(pthread_create); 191 INTERCEPT_FUNCTION(pthread_create);
diff --git a/libsanitizer/hwasan/hwasan_interface_internal.h b/libsanitizer/hwasan/hwasan_interface_internal.h
index 25c0f94fe51..ef771add411 100644
--- a/libsanitizer/hwasan/hwasan_interface_internal.h
+++ b/libsanitizer/hwasan/hwasan_interface_internal.h
@@ -169,54 +169,6 @@ SANITIZER_INTERFACE_ATTRIBUTE
169void __hwasan_print_memory_usage(); 169void __hwasan_print_memory_usage();
170 170
171SANITIZER_INTERFACE_ATTRIBUTE 171SANITIZER_INTERFACE_ATTRIBUTE
172int __sanitizer_posix_memalign(void **memptr, uptr alignment, uptr size);
173
174SANITIZER_INTERFACE_ATTRIBUTE
175void * __sanitizer_memalign(uptr alignment, uptr size);
176
177SANITIZER_INTERFACE_ATTRIBUTE
178void * __sanitizer_aligned_alloc(uptr alignment, uptr size);
179
180SANITIZER_INTERFACE_ATTRIBUTE
181void * __sanitizer___libc_memalign(uptr alignment, uptr size);
182
183SANITIZER_INTERFACE_ATTRIBUTE
184void * __sanitizer_valloc(uptr size);
185
186SANITIZER_INTERFACE_ATTRIBUTE
187void * __sanitizer_pvalloc(uptr size);
188
189SANITIZER_INTERFACE_ATTRIBUTE
190void __sanitizer_free(void *ptr);
191
192SANITIZER_INTERFACE_ATTRIBUTE
193void __sanitizer_cfree(void *ptr);
194
195SANITIZER_INTERFACE_ATTRIBUTE
196uptr __sanitizer_malloc_usable_size(const void *ptr);
197
198SANITIZER_INTERFACE_ATTRIBUTE
199__hwasan::__sanitizer_struct_mallinfo __sanitizer_mallinfo();
200
201SANITIZER_INTERFACE_ATTRIBUTE
202int __sanitizer_mallopt(int cmd, int value);
203
204SANITIZER_INTERFACE_ATTRIBUTE
205void __sanitizer_malloc_stats(void);
206
207SANITIZER_INTERFACE_ATTRIBUTE
208void * __sanitizer_calloc(uptr nmemb, uptr size);
209
210SANITIZER_INTERFACE_ATTRIBUTE
211void * __sanitizer_realloc(void *ptr, uptr size);
212
213SANITIZER_INTERFACE_ATTRIBUTE
214void * __sanitizer_reallocarray(void *ptr, uptr nmemb, uptr size);
215
216SANITIZER_INTERFACE_ATTRIBUTE
217void * __sanitizer_malloc(uptr size);
218
219SANITIZER_INTERFACE_ATTRIBUTE
220void *__hwasan_memcpy(void *dst, const void *src, uptr size); 172void *__hwasan_memcpy(void *dst, const void *src, uptr size);
221SANITIZER_INTERFACE_ATTRIBUTE 173SANITIZER_INTERFACE_ATTRIBUTE
222void *__hwasan_memset(void *s, int c, uptr n); 174void *__hwasan_memset(void *s, int c, uptr n);
diff --git a/libsanitizer/hwasan/hwasan_linux.cpp b/libsanitizer/hwasan/hwasan_linux.cpp
index e22723529f4..a86ec28507f 100644
--- a/libsanitizer/hwasan/hwasan_linux.cpp
+++ b/libsanitizer/hwasan/hwasan_linux.cpp
@@ -15,30 +15,30 @@
15#include "sanitizer_common/sanitizer_platform.h" 15#include "sanitizer_common/sanitizer_platform.h"
16#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD 16#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
17 17
18#include "hwasan.h" 18# include <dlfcn.h>
19#include "hwasan_dynamic_shadow.h" 19# include <elf.h>
20#include "hwasan_interface_internal.h" 20# include <errno.h>
21#include "hwasan_mapping.h" 21# include <link.h>
22#include "hwasan_report.h" 22# include <pthread.h>
23#include "hwasan_thread.h" 23# include <signal.h>
24#include "hwasan_thread_list.h" 24# include <stdio.h>
25 25# include <stdlib.h>
26#include <dlfcn.h> 26# include <sys/prctl.h>
27#include <elf.h> 27# include <sys/resource.h>
28#include <link.h> 28# include <sys/time.h>
29#include <pthread.h> 29# include <unistd.h>
30#include <signal.h> 30# include <unwind.h>
31#include <stdio.h> 31
32#include <stdlib.h> 32# include "hwasan.h"
33#include <sys/resource.h> 33# include "hwasan_dynamic_shadow.h"
34#include <sys/time.h> 34# include "hwasan_interface_internal.h"
35#include <unistd.h> 35# include "hwasan_mapping.h"
36#include <unwind.h> 36# include "hwasan_report.h"
37#include <sys/prctl.h> 37# include "hwasan_thread.h"
38#include <errno.h> 38# include "hwasan_thread_list.h"
39 39# include "sanitizer_common/sanitizer_common.h"
40#include "sanitizer_common/sanitizer_common.h" 40# include "sanitizer_common/sanitizer_procmaps.h"
41#include "sanitizer_common/sanitizer_procmaps.h" 41# include "sanitizer_common/sanitizer_stackdepot.h"
42 42
43// Configurations of HWASAN_WITH_INTERCEPTORS and SANITIZER_ANDROID. 43// Configurations of HWASAN_WITH_INTERCEPTORS and SANITIZER_ANDROID.
44// 44//
@@ -50,10 +50,10 @@
50// Tested with check-hwasan on x86_64-linux. 50// Tested with check-hwasan on x86_64-linux.
51// HWASAN_WITH_INTERCEPTORS=ON, SANITIZER_ANDROID=ON 51// HWASAN_WITH_INTERCEPTORS=ON, SANITIZER_ANDROID=ON
52// Tested with check-hwasan on aarch64-linux-android. 52// Tested with check-hwasan on aarch64-linux-android.
53#if !SANITIZER_ANDROID 53# if !SANITIZER_ANDROID
54SANITIZER_INTERFACE_ATTRIBUTE 54SANITIZER_INTERFACE_ATTRIBUTE
55THREADLOCAL uptr __hwasan_tls; 55THREADLOCAL uptr __hwasan_tls;
56#endif 56# endif
57 57
58namespace __hwasan { 58namespace __hwasan {
59 59
@@ -111,9 +111,9 @@ static void InitializeShadowBaseAddress(uptr shadow_size_bytes) {
111} 111}
112 112
113void InitializeOsSupport() { 113void InitializeOsSupport() {
114#define PR_SET_TAGGED_ADDR_CTRL 55 114# define PR_SET_TAGGED_ADDR_CTRL 55
115#define PR_GET_TAGGED_ADDR_CTRL 56 115# define PR_GET_TAGGED_ADDR_CTRL 56
116#define PR_TAGGED_ADDR_ENABLE (1UL << 0) 116# define PR_TAGGED_ADDR_ENABLE (1UL << 0)
117 // Check we're running on a kernel that can use the tagged address ABI. 117 // Check we're running on a kernel that can use the tagged address ABI.
118 int local_errno = 0; 118 int local_errno = 0;
119 if (internal_iserror(internal_prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0), 119 if (internal_iserror(internal_prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0),
@@ -164,9 +164,9 @@ void InitializeOsSupport() {
164 Die(); 164 Die();
165 } 165 }
166 } 166 }
167#undef PR_SET_TAGGED_ADDR_CTRL 167# undef PR_SET_TAGGED_ADDR_CTRL
168#undef PR_GET_TAGGED_ADDR_CTRL 168# undef PR_GET_TAGGED_ADDR_CTRL
169#undef PR_TAGGED_ADDR_ENABLE 169# undef PR_TAGGED_ADDR_ENABLE
170} 170}
171 171
172bool InitShadow() { 172bool InitShadow() {
@@ -241,12 +241,11 @@ bool MemIsApp(uptr p) {
241 CHECK(GetTagFromPointer(p) == 0); 241 CHECK(GetTagFromPointer(p) == 0);
242# endif 242# endif
243 243
244 return p >= kHighMemStart || (p >= kLowMemStart && p <= kLowMemEnd); 244 return (p >= kHighMemStart && p <= kHighMemEnd) ||
245 (p >= kLowMemStart && p <= kLowMemEnd);
245} 246}
246 247
247void InstallAtExitHandler() { 248void InstallAtExitHandler() { atexit(HwasanAtExit); }
248 atexit(HwasanAtExit);
249}
250 249
251// ---------------------- TSD ---------------- {{{1 250// ---------------------- TSD ---------------- {{{1
252 251
@@ -262,7 +261,7 @@ extern "C" void __hwasan_thread_exit() {
262 hwasanThreadList().ReleaseThread(t); 261 hwasanThreadList().ReleaseThread(t);
263} 262}
264 263
265#if HWASAN_WITH_INTERCEPTORS 264# if HWASAN_WITH_INTERCEPTORS
266static pthread_key_t tsd_key; 265static pthread_key_t tsd_key;
267static bool tsd_key_inited = false; 266static bool tsd_key_inited = false;
268 267
@@ -286,22 +285,18 @@ void HwasanTSDInit() {
286 tsd_key_inited = true; 285 tsd_key_inited = true;
287 CHECK_EQ(0, pthread_key_create(&tsd_key, HwasanTSDDtor)); 286 CHECK_EQ(0, pthread_key_create(&tsd_key, HwasanTSDDtor));
288} 287}
289#else 288# else
290void HwasanTSDInit() {} 289void HwasanTSDInit() {}
291void HwasanTSDThreadInit() {} 290void HwasanTSDThreadInit() {}
292#endif 291# endif
293 292
294#if SANITIZER_ANDROID 293# if SANITIZER_ANDROID
295uptr *GetCurrentThreadLongPtr() { 294uptr *GetCurrentThreadLongPtr() { return (uptr *)get_android_tls_ptr(); }
296 return (uptr *)get_android_tls_ptr(); 295# else
297} 296uptr *GetCurrentThreadLongPtr() { return &__hwasan_tls; }
298#else 297# endif
299uptr *GetCurrentThreadLongPtr() {
300 return &__hwasan_tls;
301}
302#endif
303 298
304#if SANITIZER_ANDROID 299# if SANITIZER_ANDROID
305void AndroidTestTlsSlot() { 300void AndroidTestTlsSlot() {
306 uptr kMagicValue = 0x010203040A0B0C0D; 301 uptr kMagicValue = 0x010203040A0B0C0D;
307 uptr *tls_ptr = GetCurrentThreadLongPtr(); 302 uptr *tls_ptr = GetCurrentThreadLongPtr();
@@ -316,9 +311,9 @@ void AndroidTestTlsSlot() {
316 } 311 }
317 *tls_ptr = old_value; 312 *tls_ptr = old_value;
318} 313}
319#else 314# else
320void AndroidTestTlsSlot() {} 315void AndroidTestTlsSlot() {}
321#endif 316# endif
322 317
323static AccessInfo GetAccessInfo(siginfo_t *info, ucontext_t *uc) { 318static AccessInfo GetAccessInfo(siginfo_t *info, ucontext_t *uc) {
324 // Access type is passed in a platform dependent way (see below) and encoded 319 // Access type is passed in a platform dependent way (see below) and encoded
@@ -326,32 +321,32 @@ static AccessInfo GetAccessInfo(siginfo_t *info, ucontext_t *uc) {
326 // recoverable. Valid values of Y are 0 to 4, which are interpreted as 321 // recoverable. Valid values of Y are 0 to 4, which are interpreted as
327 // log2(access_size), and 0xF, which means that access size is passed via 322 // log2(access_size), and 0xF, which means that access size is passed via
328 // platform dependent register (see below). 323 // platform dependent register (see below).
329#if defined(__aarch64__) 324# if defined(__aarch64__)
330 // Access type is encoded in BRK immediate as 0x900 + 0xXY. For Y == 0xF, 325 // Access type is encoded in BRK immediate as 0x900 + 0xXY. For Y == 0xF,
331 // access size is stored in X1 register. Access address is always in X0 326 // access size is stored in X1 register. Access address is always in X0
332 // register. 327 // register.
333 uptr pc = (uptr)info->si_addr; 328 uptr pc = (uptr)info->si_addr;
334 const unsigned code = ((*(u32 *)pc) >> 5) & 0xffff; 329 const unsigned code = ((*(u32 *)pc) >> 5) & 0xffff;
335 if ((code & 0xff00) != 0x900) 330 if ((code & 0xff00) != 0x900)
336 return AccessInfo{}; // Not ours. 331 return AccessInfo{}; // Not ours.
337 332
338 const bool is_store = code & 0x10; 333 const bool is_store = code & 0x10;
339 const bool recover = code & 0x20; 334 const bool recover = code & 0x20;
340 const uptr addr = uc->uc_mcontext.regs[0]; 335 const uptr addr = uc->uc_mcontext.regs[0];
341 const unsigned size_log = code & 0xf; 336 const unsigned size_log = code & 0xf;
342 if (size_log > 4 && size_log != 0xf) 337 if (size_log > 4 && size_log != 0xf)
343 return AccessInfo{}; // Not ours. 338 return AccessInfo{}; // Not ours.
344 const uptr size = size_log == 0xf ? uc->uc_mcontext.regs[1] : 1U << size_log; 339 const uptr size = size_log == 0xf ? uc->uc_mcontext.regs[1] : 1U << size_log;
345 340
346#elif defined(__x86_64__) 341# elif defined(__x86_64__)
347 // Access type is encoded in the instruction following INT3 as 342 // Access type is encoded in the instruction following INT3 as
348 // NOP DWORD ptr [EAX + 0x40 + 0xXY]. For Y == 0xF, access size is stored in 343 // NOP DWORD ptr [EAX + 0x40 + 0xXY]. For Y == 0xF, access size is stored in
349 // RSI register. Access address is always in RDI register. 344 // RSI register. Access address is always in RDI register.
350 uptr pc = (uptr)uc->uc_mcontext.gregs[REG_RIP]; 345 uptr pc = (uptr)uc->uc_mcontext.gregs[REG_RIP];
351 uint8_t *nop = (uint8_t*)pc; 346 uint8_t *nop = (uint8_t *)pc;
352 if (*nop != 0x0f || *(nop + 1) != 0x1f || *(nop + 2) != 0x40 || 347 if (*nop != 0x0f || *(nop + 1) != 0x1f || *(nop + 2) != 0x40 ||
353 *(nop + 3) < 0x40) 348 *(nop + 3) < 0x40)
354 return AccessInfo{}; // Not ours. 349 return AccessInfo{}; // Not ours.
355 const unsigned code = *(nop + 3); 350 const unsigned code = *(nop + 3);
356 351
357 const bool is_store = code & 0x10; 352 const bool is_store = code & 0x10;
@@ -359,13 +354,13 @@ static AccessInfo GetAccessInfo(siginfo_t *info, ucontext_t *uc) {
359 const uptr addr = uc->uc_mcontext.gregs[REG_RDI]; 354 const uptr addr = uc->uc_mcontext.gregs[REG_RDI];
360 const unsigned size_log = code & 0xf; 355 const unsigned size_log = code & 0xf;
361 if (size_log > 4 && size_log != 0xf) 356 if (size_log > 4 && size_log != 0xf)
362 return AccessInfo{}; // Not ours. 357 return AccessInfo{}; // Not ours.
363 const uptr size = 358 const uptr size =
364 size_log == 0xf ? uc->uc_mcontext.gregs[REG_RSI] : 1U << size_log; 359 size_log == 0xf ? uc->uc_mcontext.gregs[REG_RSI] : 1U << size_log;
365 360
366#else 361# else
367# error Unsupported architecture 362# error Unsupported architecture
368#endif 363# endif
369 364
370 return AccessInfo{addr, size, is_store, !is_store, recover}; 365 return AccessInfo{addr, size, is_store, !is_store, recover};
371} 366}
@@ -378,12 +373,12 @@ static bool HwasanOnSIGTRAP(int signo, siginfo_t *info, ucontext_t *uc) {
378 SignalContext sig{info, uc}; 373 SignalContext sig{info, uc};
379 HandleTagMismatch(ai, StackTrace::GetNextInstructionPc(sig.pc), sig.bp, uc); 374 HandleTagMismatch(ai, StackTrace::GetNextInstructionPc(sig.pc), sig.bp, uc);
380 375
381#if defined(__aarch64__) 376# if defined(__aarch64__)
382 uc->uc_mcontext.pc += 4; 377 uc->uc_mcontext.pc += 4;
383#elif defined(__x86_64__) 378# elif defined(__x86_64__)
384#else 379# else
385# error Unsupported architecture 380# error Unsupported architecture
386#endif 381# endif
387 return true; 382 return true;
388} 383}
389 384
@@ -396,7 +391,7 @@ static void OnStackUnwind(const SignalContext &sig, const void *,
396void HwasanOnDeadlySignal(int signo, void *info, void *context) { 391void HwasanOnDeadlySignal(int signo, void *info, void *context) {
397 // Probably a tag mismatch. 392 // Probably a tag mismatch.
398 if (signo == SIGTRAP) 393 if (signo == SIGTRAP)
399 if (HwasanOnSIGTRAP(signo, (siginfo_t *)info, (ucontext_t*)context)) 394 if (HwasanOnSIGTRAP(signo, (siginfo_t *)info, (ucontext_t *)context))
400 return; 395 return;
401 396
402 HandleDeadlySignal(info, context, GetTid(), &OnStackUnwind, nullptr); 397 HandleDeadlySignal(info, context, GetTid(), &OnStackUnwind, nullptr);
@@ -435,6 +430,18 @@ uptr TagMemoryAligned(uptr p, uptr size, tag_t tag) {
435 return AddTagToPointer(p, tag); 430 return AddTagToPointer(p, tag);
436} 431}
437 432
438} // namespace __hwasan 433void HwasanInstallAtForkHandler() {
434 auto before = []() {
435 HwasanAllocatorLock();
436 StackDepotLockAll();
437 };
438 auto after = []() {
439 StackDepotUnlockAll();
440 HwasanAllocatorUnlock();
441 };
442 pthread_atfork(before, after, after);
443}
444
445} // namespace __hwasan
439 446
440#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD 447#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
diff --git a/libsanitizer/hwasan/hwasan_report.cpp b/libsanitizer/hwasan/hwasan_report.cpp
index 44047c9fdaf..9b3b661b74b 100644
--- a/libsanitizer/hwasan/hwasan_report.cpp
+++ b/libsanitizer/hwasan/hwasan_report.cpp
@@ -37,7 +37,7 @@ namespace __hwasan {
37class ScopedReport { 37class ScopedReport {
38 public: 38 public:
39 ScopedReport(bool fatal = false) : error_message_(1), fatal(fatal) { 39 ScopedReport(bool fatal = false) : error_message_(1), fatal(fatal) {
40 BlockingMutexLock lock(&error_message_lock_); 40 Lock lock(&error_message_lock_);
41 error_message_ptr_ = fatal ? &error_message_ : nullptr; 41 error_message_ptr_ = fatal ? &error_message_ : nullptr;
42 ++hwasan_report_count; 42 ++hwasan_report_count;
43 } 43 }
@@ -45,7 +45,7 @@ class ScopedReport {
45 ~ScopedReport() { 45 ~ScopedReport() {
46 void (*report_cb)(const char *); 46 void (*report_cb)(const char *);
47 { 47 {
48 BlockingMutexLock lock(&error_message_lock_); 48 Lock lock(&error_message_lock_);
49 report_cb = error_report_callback_; 49 report_cb = error_report_callback_;
50 error_message_ptr_ = nullptr; 50 error_message_ptr_ = nullptr;
51 } 51 }
@@ -61,7 +61,7 @@ class ScopedReport {
61 } 61 }
62 62
63 static void MaybeAppendToErrorMessage(const char *msg) { 63 static void MaybeAppendToErrorMessage(const char *msg) {
64 BlockingMutexLock lock(&error_message_lock_); 64 Lock lock(&error_message_lock_);
65 if (!error_message_ptr_) 65 if (!error_message_ptr_)
66 return; 66 return;
67 uptr len = internal_strlen(msg); 67 uptr len = internal_strlen(msg);
@@ -72,7 +72,7 @@ class ScopedReport {
72 } 72 }
73 73
74 static void SetErrorReportCallback(void (*callback)(const char *)) { 74 static void SetErrorReportCallback(void (*callback)(const char *)) {
75 BlockingMutexLock lock(&error_message_lock_); 75 Lock lock(&error_message_lock_);
76 error_report_callback_ = callback; 76 error_report_callback_ = callback;
77 } 77 }
78 78
@@ -82,12 +82,12 @@ class ScopedReport {
82 bool fatal; 82 bool fatal;
83 83
84 static InternalMmapVector<char> *error_message_ptr_; 84 static InternalMmapVector<char> *error_message_ptr_;
85 static BlockingMutex error_message_lock_; 85 static Mutex error_message_lock_;
86 static void (*error_report_callback_)(const char *); 86 static void (*error_report_callback_)(const char *);
87}; 87};
88 88
89InternalMmapVector<char> *ScopedReport::error_message_ptr_; 89InternalMmapVector<char> *ScopedReport::error_message_ptr_;
90BlockingMutex ScopedReport::error_message_lock_; 90Mutex ScopedReport::error_message_lock_;
91void (*ScopedReport::error_report_callback_)(const char *); 91void (*ScopedReport::error_report_callback_)(const char *);
92 92
93// If there is an active ScopedReport, append to its error message. 93// If there is an active ScopedReport, append to its error message.
@@ -351,14 +351,16 @@ static void ShowHeapOrGlobalCandidate(uptr untagged_addr, tag_t *candidate,
351 uptr size = GetGlobalSizeFromDescriptor(mem); 351 uptr size = GetGlobalSizeFromDescriptor(mem);
352 if (size == 0) 352 if (size == 0)
353 // We couldn't find the size of the global from the descriptors. 353 // We couldn't find the size of the global from the descriptors.
354 Printf("%p is located to the %s of a global variable in (%s+0x%x)\n", 354 Printf(
355 untagged_addr, candidate == left ? "right" : "left", module_name, 355 "%p is located to the %s of a global variable in "
356 module_address); 356 "\n #0 0x%x (%s+0x%x)\n",
357 untagged_addr, candidate == left ? "right" : "left", mem,
358 module_name, module_address);
357 else 359 else
358 Printf( 360 Printf(
359 "%p is located to the %s of a %zd-byte global variable in " 361 "%p is located to the %s of a %zd-byte global variable in "
360 "(%s+0x%x)\n", 362 "\n #0 0x%x (%s+0x%x)\n",
361 untagged_addr, candidate == left ? "right" : "left", size, 363 untagged_addr, candidate == left ? "right" : "left", size, mem,
362 module_name, module_address); 364 module_name, module_address);
363 } 365 }
364 Printf("%s", d.Default()); 366 Printf("%s", d.Default());
@@ -372,6 +374,12 @@ void PrintAddressDescription(
372 int num_descriptions_printed = 0; 374 int num_descriptions_printed = 0;
373 uptr untagged_addr = UntagAddr(tagged_addr); 375 uptr untagged_addr = UntagAddr(tagged_addr);
374 376
377 if (MemIsShadow(untagged_addr)) {
378 Printf("%s%p is HWAsan shadow memory.\n%s", d.Location(), untagged_addr,
379 d.Default());
380 return;
381 }
382
375 // Print some very basic information about the address, if it's a heap. 383 // Print some very basic information about the address, if it's a heap.
376 HwasanChunkView chunk = FindHeapChunkByAddress(untagged_addr); 384 HwasanChunkView chunk = FindHeapChunkByAddress(untagged_addr);
377 if (uptr beg = chunk.Beg()) { 385 if (uptr beg = chunk.Beg()) {
@@ -549,28 +557,48 @@ static void PrintTagsAroundAddr(tag_t *tag_ptr) {
549 "description of short granule tags\n"); 557 "description of short granule tags\n");
550} 558}
551 559
560uptr GetTopPc(StackTrace *stack) {
561 return stack->size ? StackTrace::GetPreviousInstructionPc(stack->trace[0])
562 : 0;
563}
564
552void ReportInvalidFree(StackTrace *stack, uptr tagged_addr) { 565void ReportInvalidFree(StackTrace *stack, uptr tagged_addr) {
553 ScopedReport R(flags()->halt_on_error); 566 ScopedReport R(flags()->halt_on_error);
554 567
555 uptr untagged_addr = UntagAddr(tagged_addr); 568 uptr untagged_addr = UntagAddr(tagged_addr);
556 tag_t ptr_tag = GetTagFromPointer(tagged_addr); 569 tag_t ptr_tag = GetTagFromPointer(tagged_addr);
557 tag_t *tag_ptr = reinterpret_cast<tag_t*>(MemToShadow(untagged_addr)); 570 tag_t *tag_ptr = nullptr;
558 tag_t mem_tag = *tag_ptr; 571 tag_t mem_tag = 0;
572 if (MemIsApp(untagged_addr)) {
573 tag_ptr = reinterpret_cast<tag_t *>(MemToShadow(untagged_addr));
574 if (MemIsShadow(reinterpret_cast<uptr>(tag_ptr)))
575 mem_tag = *tag_ptr;
576 else
577 tag_ptr = nullptr;
578 }
559 Decorator d; 579 Decorator d;
560 Printf("%s", d.Error()); 580 Printf("%s", d.Error());
561 uptr pc = stack->size ? stack->trace[0] : 0; 581 uptr pc = GetTopPc(stack);
562 const char *bug_type = "invalid-free"; 582 const char *bug_type = "invalid-free";
563 Report("ERROR: %s: %s on address %p at pc %p\n", SanitizerToolName, bug_type, 583 const Thread *thread = GetCurrentThread();
564 untagged_addr, pc); 584 if (thread) {
585 Report("ERROR: %s: %s on address %p at pc %p on thread T%zd\n",
586 SanitizerToolName, bug_type, untagged_addr, pc, thread->unique_id());
587 } else {
588 Report("ERROR: %s: %s on address %p at pc %p on unknown thread\n",
589 SanitizerToolName, bug_type, untagged_addr, pc);
590 }
565 Printf("%s", d.Access()); 591 Printf("%s", d.Access());
566 Printf("tags: %02x/%02x (ptr/mem)\n", ptr_tag, mem_tag); 592 if (tag_ptr)
593 Printf("tags: %02x/%02x (ptr/mem)\n", ptr_tag, mem_tag);
567 Printf("%s", d.Default()); 594 Printf("%s", d.Default());
568 595
569 stack->Print(); 596 stack->Print();
570 597
571 PrintAddressDescription(tagged_addr, 0, nullptr); 598 PrintAddressDescription(tagged_addr, 0, nullptr);
572 599
573 PrintTagsAroundAddr(tag_ptr); 600 if (tag_ptr)
601 PrintTagsAroundAddr(tag_ptr);
574 602
575 ReportErrorSummary(bug_type, stack); 603 ReportErrorSummary(bug_type, stack);
576} 604}
@@ -578,6 +606,15 @@ void ReportInvalidFree(StackTrace *stack, uptr tagged_addr) {
578void ReportTailOverwritten(StackTrace *stack, uptr tagged_addr, uptr orig_size, 606void ReportTailOverwritten(StackTrace *stack, uptr tagged_addr, uptr orig_size,
579 const u8 *expected) { 607 const u8 *expected) {
580 uptr tail_size = kShadowAlignment - (orig_size % kShadowAlignment); 608 uptr tail_size = kShadowAlignment - (orig_size % kShadowAlignment);
609 u8 actual_expected[kShadowAlignment];
610 internal_memcpy(actual_expected, expected, tail_size);
611 tag_t ptr_tag = GetTagFromPointer(tagged_addr);
612 // Short granule is stashed in the last byte of the magic string. To avoid
613 // confusion, make the expected magic string contain the short granule tag.
614 if (orig_size % kShadowAlignment != 0) {
615 actual_expected[tail_size - 1] = ptr_tag;
616 }
617
581 ScopedReport R(flags()->halt_on_error); 618 ScopedReport R(flags()->halt_on_error);
582 Decorator d; 619 Decorator d;
583 uptr untagged_addr = UntagAddr(tagged_addr); 620 uptr untagged_addr = UntagAddr(tagged_addr);
@@ -614,14 +651,13 @@ void ReportTailOverwritten(StackTrace *stack, uptr tagged_addr, uptr orig_size,
614 s.append("Expected: "); 651 s.append("Expected: ");
615 for (uptr i = 0; i < kShadowAlignment - tail_size; i++) 652 for (uptr i = 0; i < kShadowAlignment - tail_size; i++)
616 s.append(".. "); 653 s.append(".. ");
617 for (uptr i = 0; i < tail_size; i++) 654 for (uptr i = 0; i < tail_size; i++) s.append("%02x ", actual_expected[i]);
618 s.append("%02x ", expected[i]);
619 s.append("\n"); 655 s.append("\n");
620 s.append(" "); 656 s.append(" ");
621 for (uptr i = 0; i < kShadowAlignment - tail_size; i++) 657 for (uptr i = 0; i < kShadowAlignment - tail_size; i++)
622 s.append(" "); 658 s.append(" ");
623 for (uptr i = 0; i < tail_size; i++) 659 for (uptr i = 0; i < tail_size; i++)
624 s.append("%s ", expected[i] != tail[i] ? "^^" : " "); 660 s.append("%s ", actual_expected[i] != tail[i] ? "^^" : " ");
625 661
626 s.append("\nThis error occurs when a buffer overflow overwrites memory\n" 662 s.append("\nThis error occurs when a buffer overflow overwrites memory\n"
627 "to the right of a heap object, but within the %zd-byte granule, e.g.\n" 663 "to the right of a heap object, but within the %zd-byte granule, e.g.\n"
@@ -647,11 +683,11 @@ void ReportTagMismatch(StackTrace *stack, uptr tagged_addr, uptr access_size,
647 GetCurrentThread()->stack_allocations()); 683 GetCurrentThread()->stack_allocations());
648 684
649 Decorator d; 685 Decorator d;
650 Printf("%s", d.Error());
651 uptr untagged_addr = UntagAddr(tagged_addr); 686 uptr untagged_addr = UntagAddr(tagged_addr);
652 // TODO: when possible, try to print heap-use-after-free, etc. 687 // TODO: when possible, try to print heap-use-after-free, etc.
653 const char *bug_type = "tag-mismatch"; 688 const char *bug_type = "tag-mismatch";
654 uptr pc = stack->size ? stack->trace[0] : 0; 689 uptr pc = GetTopPc(stack);
690 Printf("%s", d.Error());
655 Report("ERROR: %s: %s on address %p at pc %p\n", SanitizerToolName, bug_type, 691 Report("ERROR: %s: %s on address %p at pc %p\n", SanitizerToolName, bug_type,
656 untagged_addr, pc); 692 untagged_addr, pc);
657 693
diff --git a/libsanitizer/hwasan/hwasan_setjmp.S b/libsanitizer/hwasan/hwasan_setjmp_aarch64.S
index 381af63363c..744748a5101 100644
--- a/libsanitizer/hwasan/hwasan_setjmp.S
+++ b/libsanitizer/hwasan/hwasan_setjmp_aarch64.S
@@ -1,4 +1,4 @@
1//===-- hwasan_setjmp.S --------------------------------------------------------===// 1//===-- hwasan_setjmp_aarch64.S -------------------------------------------===//
2// 2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information. 4// See https://llvm.org/LICENSE.txt for license information.
@@ -29,7 +29,7 @@
29// Hence we have to write this function in assembly. 29// Hence we have to write this function in assembly.
30 30
31.section .text 31.section .text
32.file "hwasan_setjmp.S" 32.file "hwasan_setjmp_aarch64.S"
33 33
34.global __interceptor_setjmp 34.global __interceptor_setjmp
35ASM_TYPE_FUNCTION(__interceptor_setjmp) 35ASM_TYPE_FUNCTION(__interceptor_setjmp)
@@ -80,24 +80,19 @@ __interceptor_sigsetjmp:
80ASM_SIZE(__interceptor_sigsetjmp) 80ASM_SIZE(__interceptor_sigsetjmp)
81 81
82 82
83.macro ALIAS first second 83.macro WEAK_ALIAS first second
84 .globl \second 84 .weak \second
85 .equ \second\(), \first 85 .equ \second\(), \first
86.endm 86.endm
87 87
88#if SANITIZER_ANDROID 88#if SANITIZER_ANDROID
89ALIAS __interceptor_sigsetjmp, sigsetjmp 89WEAK_ALIAS __interceptor_sigsetjmp, sigsetjmp
90.weak sigsetjmp 90WEAK_ALIAS __interceptor_setjmp_bionic, setjmp
91
92ALIAS __interceptor_setjmp_bionic, setjmp
93.weak setjmp
94#else 91#else
95ALIAS __interceptor_sigsetjmp, __sigsetjmp 92WEAK_ALIAS __interceptor_sigsetjmp, __sigsetjmp
96.weak __sigsetjmp
97#endif 93#endif
98 94
99ALIAS __interceptor_setjmp, _setjmp 95WEAK_ALIAS __interceptor_setjmp, _setjmp
100.weak _setjmp
101#endif 96#endif
102 97
103// We do not need executable stack. 98// We do not need executable stack.
diff --git a/libsanitizer/hwasan/hwasan_setjmp_x86_64.S b/libsanitizer/hwasan/hwasan_setjmp_x86_64.S
new file mode 100644
index 00000000000..84512d10b23
--- /dev/null
+++ b/libsanitizer/hwasan/hwasan_setjmp_x86_64.S
@@ -0,0 +1,80 @@
1//===-- hwasan_setjmp_x86_64.S --------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// setjmp interceptor for x86_64.
10//
11//===----------------------------------------------------------------------===//
12
13#include "sanitizer_common/sanitizer_asm.h"
14
15#if HWASAN_WITH_INTERCEPTORS && defined(__x86_64__)
16#include "sanitizer_common/sanitizer_platform.h"
17
18// We want to save the context of the calling function.
19// That requires
20// 1) No modification of the return address by this function.
21// 2) No modification of the stack pointer by this function.
22// 3) (no modification of any other saved register, but that's not really going
23// to occur, and hence isn't as much of a worry).
24//
25// There's essentially no way to ensure that the compiler will not modify the
26// stack pointer when compiling a C function.
27// Hence we have to write this function in assembly.
28//
29// TODO: Handle Intel CET.
30
31.section .text
32.file "hwasan_setjmp_x86_64.S"
33
34.global __interceptor_setjmp
35ASM_TYPE_FUNCTION(__interceptor_setjmp)
36__interceptor_setjmp:
37 CFI_STARTPROC
38 xorl %esi, %esi
39 jmp __interceptor_sigsetjmp
40 CFI_ENDPROC
41ASM_SIZE(__interceptor_setjmp)
42
43.global __interceptor_sigsetjmp
44ASM_TYPE_FUNCTION(__interceptor_sigsetjmp)
45__interceptor_sigsetjmp:
46 CFI_STARTPROC
47
48 // Save callee save registers.
49 mov %rbx, (0*8)(%rdi)
50 mov %rbp, (1*8)(%rdi)
51 mov %r12, (2*8)(%rdi)
52 mov %r13, (3*8)(%rdi)
53 mov %r14, (4*8)(%rdi)
54 mov %r15, (5*8)(%rdi)
55
56 // Save SP as it was in caller's frame.
57 lea 8(%rsp), %rdx
58 mov %rdx, (6*8)(%rdi)
59
60 // Save return address.
61 mov (%rsp), %rax
62 mov %rax, (7*8)(%rdi)
63
64 jmp __sigjmp_save
65
66 CFI_ENDPROC
67ASM_SIZE(__interceptor_sigsetjmp)
68
69
70.macro WEAK_ALIAS first second
71 .weak \second
72 .equ \second\(), \first
73.endm
74
75WEAK_ALIAS __interceptor_sigsetjmp, __sigsetjmp
76WEAK_ALIAS __interceptor_setjmp, _setjmp
77#endif
78
79// We do not need executable stack.
80NO_EXEC_STACK_DIRECTIVE
diff --git a/libsanitizer/hwasan/hwasan_thread.cpp b/libsanitizer/hwasan/hwasan_thread.cpp
index ee747a3beea..5b65718c4d3 100644
--- a/libsanitizer/hwasan/hwasan_thread.cpp
+++ b/libsanitizer/hwasan/hwasan_thread.cpp
@@ -45,13 +45,13 @@ void Thread::Init(uptr stack_buffer_start, uptr stack_buffer_size,
45 if (auto sz = flags()->heap_history_size) 45 if (auto sz = flags()->heap_history_size)
46 heap_allocations_ = HeapAllocationsRingBuffer::New(sz); 46 heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
47 47
48 InitStackAndTls(state);
49#if !SANITIZER_FUCHSIA 48#if !SANITIZER_FUCHSIA
50 // Do not initialize the stack ring buffer just yet on Fuchsia. Threads will 49 // Do not initialize the stack ring buffer just yet on Fuchsia. Threads will
51 // be initialized before we enter the thread itself, so we will instead call 50 // be initialized before we enter the thread itself, so we will instead call
52 // this later. 51 // this later.
53 InitStackRingBuffer(stack_buffer_start, stack_buffer_size); 52 InitStackRingBuffer(stack_buffer_start, stack_buffer_size);
54#endif 53#endif
54 InitStackAndTls(state);
55} 55}
56 56
57void Thread::InitStackRingBuffer(uptr stack_buffer_start, 57void Thread::InitStackRingBuffer(uptr stack_buffer_start,
diff --git a/libsanitizer/hwasan/hwasan_type_test.cpp b/libsanitizer/hwasan/hwasan_type_test.cpp
index 8cff495bae1..5307073fb40 100644
--- a/libsanitizer/hwasan/hwasan_type_test.cpp
+++ b/libsanitizer/hwasan/hwasan_type_test.cpp
@@ -19,7 +19,7 @@
19#define CHECK_TYPE_SIZE_FITS(TYPE) \ 19#define CHECK_TYPE_SIZE_FITS(TYPE) \
20 COMPILER_CHECK(sizeof(__hw_##TYPE) <= sizeof(TYPE)) 20 COMPILER_CHECK(sizeof(__hw_##TYPE) <= sizeof(TYPE))
21 21
22#if HWASAN_WITH_INTERCEPTORS && defined(__aarch64__) 22#if HWASAN_WITH_INTERCEPTORS
23CHECK_TYPE_SIZE_FITS(jmp_buf); 23CHECK_TYPE_SIZE_FITS(jmp_buf);
24CHECK_TYPE_SIZE_FITS(sigjmp_buf); 24CHECK_TYPE_SIZE_FITS(sigjmp_buf);
25#endif 25#endif
diff --git a/libsanitizer/include/sanitizer/asan_interface.h b/libsanitizer/include/sanitizer/asan_interface.h
index 792ef9cfaa3..9bff21c117b 100644
--- a/libsanitizer/include/sanitizer/asan_interface.h
+++ b/libsanitizer/include/sanitizer/asan_interface.h
@@ -316,7 +316,7 @@ void *__asan_addr_is_in_fake_stack(void *fake_stack, void *addr, void **beg,
316void __asan_handle_no_return(void); 316void __asan_handle_no_return(void);
317 317
318/// Update allocation stack trace for the given allocation to the current stack 318/// Update allocation stack trace for the given allocation to the current stack
319/// trace. Returns 1 if successfull, 0 if not. 319/// trace. Returns 1 if successful, 0 if not.
320int __asan_update_allocation_context(void* addr); 320int __asan_update_allocation_context(void* addr);
321 321
322#ifdef __cplusplus 322#ifdef __cplusplus
diff --git a/libsanitizer/include/sanitizer/common_interface_defs.h b/libsanitizer/include/sanitizer/common_interface_defs.h
index cd69285b8d4..692b8f70c96 100644
--- a/libsanitizer/include/sanitizer/common_interface_defs.h
+++ b/libsanitizer/include/sanitizer/common_interface_defs.h
@@ -28,7 +28,7 @@ typedef struct {
28 // Enable sandbox support in sanitizer coverage. 28 // Enable sandbox support in sanitizer coverage.
29 int coverage_sandboxed; 29 int coverage_sandboxed;
30 // File descriptor to write coverage data to. If -1 is passed, a file will 30 // File descriptor to write coverage data to. If -1 is passed, a file will
31 // be pre-opened by __sanitizer_sandobx_on_notify(). This field has no 31 // be pre-opened by __sanitizer_sandbox_on_notify(). This field has no
32 // effect if coverage_sandboxed == 0. 32 // effect if coverage_sandboxed == 0.
33 intptr_t coverage_fd; 33 intptr_t coverage_fd;
34 // If non-zero, split the coverage data into well-formed blocks. This is 34 // If non-zero, split the coverage data into well-formed blocks. This is
diff --git a/libsanitizer/include/sanitizer/dfsan_interface.h b/libsanitizer/include/sanitizer/dfsan_interface.h
index cd3b6d6e2b1..d6209a3ea2b 100644
--- a/libsanitizer/include/sanitizer/dfsan_interface.h
+++ b/libsanitizer/include/sanitizer/dfsan_interface.h
@@ -150,8 +150,7 @@ int dfsan_get_track_origins(void);
150#ifdef __cplusplus 150#ifdef __cplusplus
151} // extern "C" 151} // extern "C"
152 152
153template <typename T> 153template <typename T> void dfsan_set_label(dfsan_label label, T &data) {
154void dfsan_set_label(dfsan_label label, T &data) { // NOLINT
155 dfsan_set_label(label, (void *)&data, sizeof(T)); 154 dfsan_set_label(label, (void *)&data, sizeof(T));
156} 155}
157 156
diff --git a/libsanitizer/include/sanitizer/linux_syscall_hooks.h b/libsanitizer/include/sanitizer/linux_syscall_hooks.h
index 56eae3d40f9..3f3f1e78dfb 100644
--- a/libsanitizer/include/sanitizer/linux_syscall_hooks.h
+++ b/libsanitizer/include/sanitizer/linux_syscall_hooks.h
@@ -20,1493 +20,1502 @@
20#ifndef SANITIZER_LINUX_SYSCALL_HOOKS_H 20#ifndef SANITIZER_LINUX_SYSCALL_HOOKS_H
21#define SANITIZER_LINUX_SYSCALL_HOOKS_H 21#define SANITIZER_LINUX_SYSCALL_HOOKS_H
22 22
23#define __sanitizer_syscall_pre_time(tloc) \ 23#define __sanitizer_syscall_pre_time(tloc) \
24 __sanitizer_syscall_pre_impl_time((long)(tloc)) 24 __sanitizer_syscall_pre_impl_time((long)(tloc))
25#define __sanitizer_syscall_post_time(res, tloc) \ 25#define __sanitizer_syscall_post_time(res, tloc) \
26 __sanitizer_syscall_post_impl_time(res, (long)(tloc)) 26 __sanitizer_syscall_post_impl_time(res, (long)(tloc))
27#define __sanitizer_syscall_pre_stime(tptr) \ 27#define __sanitizer_syscall_pre_stime(tptr) \
28 __sanitizer_syscall_pre_impl_stime((long)(tptr)) 28 __sanitizer_syscall_pre_impl_stime((long)(tptr))
29#define __sanitizer_syscall_post_stime(res, tptr) \ 29#define __sanitizer_syscall_post_stime(res, tptr) \
30 __sanitizer_syscall_post_impl_stime(res, (long)(tptr)) 30 __sanitizer_syscall_post_impl_stime(res, (long)(tptr))
31#define __sanitizer_syscall_pre_gettimeofday(tv, tz) \ 31#define __sanitizer_syscall_pre_gettimeofday(tv, tz) \
32 __sanitizer_syscall_pre_impl_gettimeofday((long)(tv), (long)(tz)) 32 __sanitizer_syscall_pre_impl_gettimeofday((long)(tv), (long)(tz))
33#define __sanitizer_syscall_post_gettimeofday(res, tv, tz) \ 33#define __sanitizer_syscall_post_gettimeofday(res, tv, tz) \
34 __sanitizer_syscall_post_impl_gettimeofday(res, (long)(tv), (long)(tz)) 34 __sanitizer_syscall_post_impl_gettimeofday(res, (long)(tv), (long)(tz))
35#define __sanitizer_syscall_pre_settimeofday(tv, tz) \ 35#define __sanitizer_syscall_pre_settimeofday(tv, tz) \
36 __sanitizer_syscall_pre_impl_settimeofday((long)(tv), (long)(tz)) 36 __sanitizer_syscall_pre_impl_settimeofday((long)(tv), (long)(tz))
37#define __sanitizer_syscall_post_settimeofday(res, tv, tz) \ 37#define __sanitizer_syscall_post_settimeofday(res, tv, tz) \
38 __sanitizer_syscall_post_impl_settimeofday(res, (long)(tv), (long)(tz)) 38 __sanitizer_syscall_post_impl_settimeofday(res, (long)(tv), (long)(tz))
39#define __sanitizer_syscall_pre_adjtimex(txc_p) \ 39#define __sanitizer_syscall_pre_adjtimex(txc_p) \
40 __sanitizer_syscall_pre_impl_adjtimex((long)(txc_p)) 40 __sanitizer_syscall_pre_impl_adjtimex((long)(txc_p))
41#define __sanitizer_syscall_post_adjtimex(res, txc_p) \ 41#define __sanitizer_syscall_post_adjtimex(res, txc_p) \
42 __sanitizer_syscall_post_impl_adjtimex(res, (long)(txc_p)) 42 __sanitizer_syscall_post_impl_adjtimex(res, (long)(txc_p))
43#define __sanitizer_syscall_pre_times(tbuf) \ 43#define __sanitizer_syscall_pre_times(tbuf) \
44 __sanitizer_syscall_pre_impl_times((long)(tbuf)) 44 __sanitizer_syscall_pre_impl_times((long)(tbuf))
45#define __sanitizer_syscall_post_times(res, tbuf) \ 45#define __sanitizer_syscall_post_times(res, tbuf) \
46 __sanitizer_syscall_post_impl_times(res, (long)(tbuf)) 46 __sanitizer_syscall_post_impl_times(res, (long)(tbuf))
47#define __sanitizer_syscall_pre_gettid() __sanitizer_syscall_pre_impl_gettid() 47#define __sanitizer_syscall_pre_gettid() __sanitizer_syscall_pre_impl_gettid()
48#define __sanitizer_syscall_post_gettid(res) \ 48#define __sanitizer_syscall_post_gettid(res) \
49 __sanitizer_syscall_post_impl_gettid(res) 49 __sanitizer_syscall_post_impl_gettid(res)
50#define __sanitizer_syscall_pre_nanosleep(rqtp, rmtp) \ 50#define __sanitizer_syscall_pre_nanosleep(rqtp, rmtp) \
51 __sanitizer_syscall_pre_impl_nanosleep((long)(rqtp), (long)(rmtp)) 51 __sanitizer_syscall_pre_impl_nanosleep((long)(rqtp), (long)(rmtp))
52#define __sanitizer_syscall_post_nanosleep(res, rqtp, rmtp) \ 52#define __sanitizer_syscall_post_nanosleep(res, rqtp, rmtp) \
53 __sanitizer_syscall_post_impl_nanosleep(res, (long)(rqtp), (long)(rmtp)) 53 __sanitizer_syscall_post_impl_nanosleep(res, (long)(rqtp), (long)(rmtp))
54#define __sanitizer_syscall_pre_alarm(seconds) \ 54#define __sanitizer_syscall_pre_alarm(seconds) \
55 __sanitizer_syscall_pre_impl_alarm((long)(seconds)) 55 __sanitizer_syscall_pre_impl_alarm((long)(seconds))
56#define __sanitizer_syscall_post_alarm(res, seconds) \ 56#define __sanitizer_syscall_post_alarm(res, seconds) \
57 __sanitizer_syscall_post_impl_alarm(res, (long)(seconds)) 57 __sanitizer_syscall_post_impl_alarm(res, (long)(seconds))
58#define __sanitizer_syscall_pre_getpid() __sanitizer_syscall_pre_impl_getpid() 58#define __sanitizer_syscall_pre_getpid() __sanitizer_syscall_pre_impl_getpid()
59#define __sanitizer_syscall_post_getpid(res) \ 59#define __sanitizer_syscall_post_getpid(res) \
60 __sanitizer_syscall_post_impl_getpid(res) 60 __sanitizer_syscall_post_impl_getpid(res)
61#define __sanitizer_syscall_pre_getppid() __sanitizer_syscall_pre_impl_getppid() 61#define __sanitizer_syscall_pre_getppid() __sanitizer_syscall_pre_impl_getppid()
62#define __sanitizer_syscall_post_getppid(res) \ 62#define __sanitizer_syscall_post_getppid(res) \
63 __sanitizer_syscall_post_impl_getppid(res) 63 __sanitizer_syscall_post_impl_getppid(res)
64#define __sanitizer_syscall_pre_getuid() __sanitizer_syscall_pre_impl_getuid() 64#define __sanitizer_syscall_pre_getuid() __sanitizer_syscall_pre_impl_getuid()
65#define __sanitizer_syscall_post_getuid(res) \ 65#define __sanitizer_syscall_post_getuid(res) \
66 __sanitizer_syscall_post_impl_getuid(res) 66 __sanitizer_syscall_post_impl_getuid(res)
67#define __sanitizer_syscall_pre_geteuid() __sanitizer_syscall_pre_impl_geteuid() 67#define __sanitizer_syscall_pre_geteuid() __sanitizer_syscall_pre_impl_geteuid()
68#define __sanitizer_syscall_post_geteuid(res) \ 68#define __sanitizer_syscall_post_geteuid(res) \
69 __sanitizer_syscall_post_impl_geteuid(res) 69 __sanitizer_syscall_post_impl_geteuid(res)
70#define __sanitizer_syscall_pre_getgid() __sanitizer_syscall_pre_impl_getgid() 70#define __sanitizer_syscall_pre_getgid() __sanitizer_syscall_pre_impl_getgid()
71#define __sanitizer_syscall_post_getgid(res) \ 71#define __sanitizer_syscall_post_getgid(res) \
72 __sanitizer_syscall_post_impl_getgid(res) 72 __sanitizer_syscall_post_impl_getgid(res)
73#define __sanitizer_syscall_pre_getegid() __sanitizer_syscall_pre_impl_getegid() 73#define __sanitizer_syscall_pre_getegid() __sanitizer_syscall_pre_impl_getegid()
74#define __sanitizer_syscall_post_getegid(res) \ 74#define __sanitizer_syscall_post_getegid(res) \
75 __sanitizer_syscall_post_impl_getegid(res) 75 __sanitizer_syscall_post_impl_getegid(res)
76#define __sanitizer_syscall_pre_getresuid(ruid, euid, suid) \ 76#define __sanitizer_syscall_pre_getresuid(ruid, euid, suid) \
77 __sanitizer_syscall_pre_impl_getresuid((long)(ruid), (long)(euid), \ 77 __sanitizer_syscall_pre_impl_getresuid((long)(ruid), (long)(euid), \
78 (long)(suid)) 78 (long)(suid))
79#define __sanitizer_syscall_post_getresuid(res, ruid, euid, suid) \ 79#define __sanitizer_syscall_post_getresuid(res, ruid, euid, suid) \
80 __sanitizer_syscall_post_impl_getresuid(res, (long)(ruid), (long)(euid), \ 80 __sanitizer_syscall_post_impl_getresuid(res, (long)(ruid), (long)(euid), \
81 (long)(suid)) 81 (long)(suid))
82#define __sanitizer_syscall_pre_getresgid(rgid, egid, sgid) \ 82#define __sanitizer_syscall_pre_getresgid(rgid, egid, sgid) \
83 __sanitizer_syscall_pre_impl_getresgid((long)(rgid), (long)(egid), \ 83 __sanitizer_syscall_pre_impl_getresgid((long)(rgid), (long)(egid), \
84 (long)(sgid)) 84 (long)(sgid))
85#define __sanitizer_syscall_post_getresgid(res, rgid, egid, sgid) \ 85#define __sanitizer_syscall_post_getresgid(res, rgid, egid, sgid) \
86 __sanitizer_syscall_post_impl_getresgid(res, (long)(rgid), (long)(egid), \ 86 __sanitizer_syscall_post_impl_getresgid(res, (long)(rgid), (long)(egid), \
87 (long)(sgid)) 87 (long)(sgid))
88#define __sanitizer_syscall_pre_getpgid(pid) \ 88#define __sanitizer_syscall_pre_getpgid(pid) \
89 __sanitizer_syscall_pre_impl_getpgid((long)(pid)) 89 __sanitizer_syscall_pre_impl_getpgid((long)(pid))
90#define __sanitizer_syscall_post_getpgid(res, pid) \ 90#define __sanitizer_syscall_post_getpgid(res, pid) \
91 __sanitizer_syscall_post_impl_getpgid(res, (long)(pid)) 91 __sanitizer_syscall_post_impl_getpgid(res, (long)(pid))
92#define __sanitizer_syscall_pre_getpgrp() __sanitizer_syscall_pre_impl_getpgrp() 92#define __sanitizer_syscall_pre_getpgrp() __sanitizer_syscall_pre_impl_getpgrp()
93#define __sanitizer_syscall_post_getpgrp(res) \ 93#define __sanitizer_syscall_post_getpgrp(res) \
94 __sanitizer_syscall_post_impl_getpgrp(res) 94 __sanitizer_syscall_post_impl_getpgrp(res)
95#define __sanitizer_syscall_pre_getsid(pid) \ 95#define __sanitizer_syscall_pre_getsid(pid) \
96 __sanitizer_syscall_pre_impl_getsid((long)(pid)) 96 __sanitizer_syscall_pre_impl_getsid((long)(pid))
97#define __sanitizer_syscall_post_getsid(res, pid) \ 97#define __sanitizer_syscall_post_getsid(res, pid) \
98 __sanitizer_syscall_post_impl_getsid(res, (long)(pid)) 98 __sanitizer_syscall_post_impl_getsid(res, (long)(pid))
99#define __sanitizer_syscall_pre_getgroups(gidsetsize, grouplist) \ 99#define __sanitizer_syscall_pre_getgroups(gidsetsize, grouplist) \
100 __sanitizer_syscall_pre_impl_getgroups((long)(gidsetsize), (long)(grouplist)) 100 __sanitizer_syscall_pre_impl_getgroups((long)(gidsetsize), (long)(grouplist))
101#define __sanitizer_syscall_post_getgroups(res, gidsetsize, grouplist) \ 101#define __sanitizer_syscall_post_getgroups(res, gidsetsize, grouplist) \
102 __sanitizer_syscall_post_impl_getgroups(res, (long)(gidsetsize), \ 102 __sanitizer_syscall_post_impl_getgroups(res, (long)(gidsetsize), \
103 (long)(grouplist)) 103 (long)(grouplist))
104#define __sanitizer_syscall_pre_setregid(rgid, egid) \ 104#define __sanitizer_syscall_pre_setregid(rgid, egid) \
105 __sanitizer_syscall_pre_impl_setregid((long)(rgid), (long)(egid)) 105 __sanitizer_syscall_pre_impl_setregid((long)(rgid), (long)(egid))
106#define __sanitizer_syscall_post_setregid(res, rgid, egid) \ 106#define __sanitizer_syscall_post_setregid(res, rgid, egid) \
107 __sanitizer_syscall_post_impl_setregid(res, (long)(rgid), (long)(egid)) 107 __sanitizer_syscall_post_impl_setregid(res, (long)(rgid), (long)(egid))
108#define __sanitizer_syscall_pre_setgid(gid) \ 108#define __sanitizer_syscall_pre_setgid(gid) \
109 __sanitizer_syscall_pre_impl_setgid((long)(gid)) 109 __sanitizer_syscall_pre_impl_setgid((long)(gid))
110#define __sanitizer_syscall_post_setgid(res, gid) \ 110#define __sanitizer_syscall_post_setgid(res, gid) \
111 __sanitizer_syscall_post_impl_setgid(res, (long)(gid)) 111 __sanitizer_syscall_post_impl_setgid(res, (long)(gid))
112#define __sanitizer_syscall_pre_setreuid(ruid, euid) \ 112#define __sanitizer_syscall_pre_setreuid(ruid, euid) \
113 __sanitizer_syscall_pre_impl_setreuid((long)(ruid), (long)(euid)) 113 __sanitizer_syscall_pre_impl_setreuid((long)(ruid), (long)(euid))
114#define __sanitizer_syscall_post_setreuid(res, ruid, euid) \ 114#define __sanitizer_syscall_post_setreuid(res, ruid, euid) \
115 __sanitizer_syscall_post_impl_setreuid(res, (long)(ruid), (long)(euid)) 115 __sanitizer_syscall_post_impl_setreuid(res, (long)(ruid), (long)(euid))
116#define __sanitizer_syscall_pre_setuid(uid) \ 116#define __sanitizer_syscall_pre_setuid(uid) \
117 __sanitizer_syscall_pre_impl_setuid((long)(uid)) 117 __sanitizer_syscall_pre_impl_setuid((long)(uid))
118#define __sanitizer_syscall_post_setuid(res, uid) \ 118#define __sanitizer_syscall_post_setuid(res, uid) \
119 __sanitizer_syscall_post_impl_setuid(res, (long)(uid)) 119 __sanitizer_syscall_post_impl_setuid(res, (long)(uid))
120#define __sanitizer_syscall_pre_setresuid(ruid, euid, suid) \ 120#define __sanitizer_syscall_pre_setresuid(ruid, euid, suid) \
121 __sanitizer_syscall_pre_impl_setresuid((long)(ruid), (long)(euid), \ 121 __sanitizer_syscall_pre_impl_setresuid((long)(ruid), (long)(euid), \
122 (long)(suid)) 122 (long)(suid))
123#define __sanitizer_syscall_post_setresuid(res, ruid, euid, suid) \ 123#define __sanitizer_syscall_post_setresuid(res, ruid, euid, suid) \
124 __sanitizer_syscall_post_impl_setresuid(res, (long)(ruid), (long)(euid), \ 124 __sanitizer_syscall_post_impl_setresuid(res, (long)(ruid), (long)(euid), \
125 (long)(suid)) 125 (long)(suid))
126#define __sanitizer_syscall_pre_setresgid(rgid, egid, sgid) \ 126#define __sanitizer_syscall_pre_setresgid(rgid, egid, sgid) \
127 __sanitizer_syscall_pre_impl_setresgid((long)(rgid), (long)(egid), \ 127 __sanitizer_syscall_pre_impl_setresgid((long)(rgid), (long)(egid), \
128 (long)(sgid)) 128 (long)(sgid))
129#define __sanitizer_syscall_post_setresgid(res, rgid, egid, sgid) \ 129#define __sanitizer_syscall_post_setresgid(res, rgid, egid, sgid) \
130 __sanitizer_syscall_post_impl_setresgid(res, (long)(rgid), (long)(egid), \ 130 __sanitizer_syscall_post_impl_setresgid(res, (long)(rgid), (long)(egid), \
131 (long)(sgid)) 131 (long)(sgid))
132#define __sanitizer_syscall_pre_setfsuid(uid) \ 132#define __sanitizer_syscall_pre_setfsuid(uid) \
133 __sanitizer_syscall_pre_impl_setfsuid((long)(uid)) 133 __sanitizer_syscall_pre_impl_setfsuid((long)(uid))
134#define __sanitizer_syscall_post_setfsuid(res, uid) \ 134#define __sanitizer_syscall_post_setfsuid(res, uid) \
135 __sanitizer_syscall_post_impl_setfsuid(res, (long)(uid)) 135 __sanitizer_syscall_post_impl_setfsuid(res, (long)(uid))
136#define __sanitizer_syscall_pre_setfsgid(gid) \ 136#define __sanitizer_syscall_pre_setfsgid(gid) \
137 __sanitizer_syscall_pre_impl_setfsgid((long)(gid)) 137 __sanitizer_syscall_pre_impl_setfsgid((long)(gid))
138#define __sanitizer_syscall_post_setfsgid(res, gid) \ 138#define __sanitizer_syscall_post_setfsgid(res, gid) \
139 __sanitizer_syscall_post_impl_setfsgid(res, (long)(gid)) 139 __sanitizer_syscall_post_impl_setfsgid(res, (long)(gid))
140#define __sanitizer_syscall_pre_setpgid(pid, pgid) \ 140#define __sanitizer_syscall_pre_setpgid(pid, pgid) \
141 __sanitizer_syscall_pre_impl_setpgid((long)(pid), (long)(pgid)) 141 __sanitizer_syscall_pre_impl_setpgid((long)(pid), (long)(pgid))
142#define __sanitizer_syscall_post_setpgid(res, pid, pgid) \ 142#define __sanitizer_syscall_post_setpgid(res, pid, pgid) \
143 __sanitizer_syscall_post_impl_setpgid(res, (long)(pid), (long)(pgid)) 143 __sanitizer_syscall_post_impl_setpgid(res, (long)(pid), (long)(pgid))
144#define __sanitizer_syscall_pre_setsid() __sanitizer_syscall_pre_impl_setsid() 144#define __sanitizer_syscall_pre_setsid() __sanitizer_syscall_pre_impl_setsid()
145#define __sanitizer_syscall_post_setsid(res) \ 145#define __sanitizer_syscall_post_setsid(res) \
146 __sanitizer_syscall_post_impl_setsid(res) 146 __sanitizer_syscall_post_impl_setsid(res)
147#define __sanitizer_syscall_pre_setgroups(gidsetsize, grouplist) \ 147#define __sanitizer_syscall_pre_setgroups(gidsetsize, grouplist) \
148 __sanitizer_syscall_pre_impl_setgroups((long)(gidsetsize), (long)(grouplist)) 148 __sanitizer_syscall_pre_impl_setgroups((long)(gidsetsize), (long)(grouplist))
149#define __sanitizer_syscall_post_setgroups(res, gidsetsize, grouplist) \ 149#define __sanitizer_syscall_post_setgroups(res, gidsetsize, grouplist) \
150 __sanitizer_syscall_post_impl_setgroups(res, (long)(gidsetsize), \ 150 __sanitizer_syscall_post_impl_setgroups(res, (long)(gidsetsize), \
151 (long)(grouplist)) 151 (long)(grouplist))
152#define __sanitizer_syscall_pre_acct(name) \ 152#define __sanitizer_syscall_pre_acct(name) \
153 __sanitizer_syscall_pre_impl_acct((long)(name)) 153 __sanitizer_syscall_pre_impl_acct((long)(name))
154#define __sanitizer_syscall_post_acct(res, name) \ 154#define __sanitizer_syscall_post_acct(res, name) \
155 __sanitizer_syscall_post_impl_acct(res, (long)(name)) 155 __sanitizer_syscall_post_impl_acct(res, (long)(name))
156#define __sanitizer_syscall_pre_capget(header, dataptr) \ 156#define __sanitizer_syscall_pre_capget(header, dataptr) \
157 __sanitizer_syscall_pre_impl_capget((long)(header), (long)(dataptr)) 157 __sanitizer_syscall_pre_impl_capget((long)(header), (long)(dataptr))
158#define __sanitizer_syscall_post_capget(res, header, dataptr) \ 158#define __sanitizer_syscall_post_capget(res, header, dataptr) \
159 __sanitizer_syscall_post_impl_capget(res, (long)(header), (long)(dataptr)) 159 __sanitizer_syscall_post_impl_capget(res, (long)(header), (long)(dataptr))
160#define __sanitizer_syscall_pre_capset(header, data) \ 160#define __sanitizer_syscall_pre_capset(header, data) \
161 __sanitizer_syscall_pre_impl_capset((long)(header), (long)(data)) 161 __sanitizer_syscall_pre_impl_capset((long)(header), (long)(data))
162#define __sanitizer_syscall_post_capset(res, header, data) \ 162#define __sanitizer_syscall_post_capset(res, header, data) \
163 __sanitizer_syscall_post_impl_capset(res, (long)(header), (long)(data)) 163 __sanitizer_syscall_post_impl_capset(res, (long)(header), (long)(data))
164#define __sanitizer_syscall_pre_personality(personality) \ 164#define __sanitizer_syscall_pre_personality(personality) \
165 __sanitizer_syscall_pre_impl_personality((long)(personality)) 165 __sanitizer_syscall_pre_impl_personality((long)(personality))
166#define __sanitizer_syscall_post_personality(res, personality) \ 166#define __sanitizer_syscall_post_personality(res, personality) \
167 __sanitizer_syscall_post_impl_personality(res, (long)(personality)) 167 __sanitizer_syscall_post_impl_personality(res, (long)(personality))
168#define __sanitizer_syscall_pre_sigpending(set) \ 168#define __sanitizer_syscall_pre_sigpending(set) \
169 __sanitizer_syscall_pre_impl_sigpending((long)(set)) 169 __sanitizer_syscall_pre_impl_sigpending((long)(set))
170#define __sanitizer_syscall_post_sigpending(res, set) \ 170#define __sanitizer_syscall_post_sigpending(res, set) \
171 __sanitizer_syscall_post_impl_sigpending(res, (long)(set)) 171 __sanitizer_syscall_post_impl_sigpending(res, (long)(set))
172#define __sanitizer_syscall_pre_sigprocmask(how, set, oset) \ 172#define __sanitizer_syscall_pre_sigprocmask(how, set, oset) \
173 __sanitizer_syscall_pre_impl_sigprocmask((long)(how), (long)(set), \ 173 __sanitizer_syscall_pre_impl_sigprocmask((long)(how), (long)(set), \
174 (long)(oset)) 174 (long)(oset))
175#define __sanitizer_syscall_post_sigprocmask(res, how, set, oset) \ 175#define __sanitizer_syscall_post_sigprocmask(res, how, set, oset) \
176 __sanitizer_syscall_post_impl_sigprocmask(res, (long)(how), (long)(set), \ 176 __sanitizer_syscall_post_impl_sigprocmask(res, (long)(how), (long)(set), \
177 (long)(oset)) 177 (long)(oset))
178#define __sanitizer_syscall_pre_getitimer(which, value) \ 178#define __sanitizer_syscall_pre_getitimer(which, value) \
179 __sanitizer_syscall_pre_impl_getitimer((long)(which), (long)(value)) 179 __sanitizer_syscall_pre_impl_getitimer((long)(which), (long)(value))
180#define __sanitizer_syscall_post_getitimer(res, which, value) \ 180#define __sanitizer_syscall_post_getitimer(res, which, value) \
181 __sanitizer_syscall_post_impl_getitimer(res, (long)(which), (long)(value)) 181 __sanitizer_syscall_post_impl_getitimer(res, (long)(which), (long)(value))
182#define __sanitizer_syscall_pre_setitimer(which, value, ovalue) \ 182#define __sanitizer_syscall_pre_setitimer(which, value, ovalue) \
183 __sanitizer_syscall_pre_impl_setitimer((long)(which), (long)(value), \ 183 __sanitizer_syscall_pre_impl_setitimer((long)(which), (long)(value), \
184 (long)(ovalue)) 184 (long)(ovalue))
185#define __sanitizer_syscall_post_setitimer(res, which, value, ovalue) \ 185#define __sanitizer_syscall_post_setitimer(res, which, value, ovalue) \
186 __sanitizer_syscall_post_impl_setitimer(res, (long)(which), (long)(value), \ 186 __sanitizer_syscall_post_impl_setitimer(res, (long)(which), (long)(value), \
187 (long)(ovalue)) 187 (long)(ovalue))
188#define __sanitizer_syscall_pre_timer_create(which_clock, timer_event_spec, \ 188#define __sanitizer_syscall_pre_timer_create(which_clock, timer_event_spec, \
189 created_timer_id) \ 189 created_timer_id) \
190 __sanitizer_syscall_pre_impl_timer_create( \ 190 __sanitizer_syscall_pre_impl_timer_create( \
191 (long)(which_clock), (long)(timer_event_spec), (long)(created_timer_id)) 191 (long)(which_clock), (long)(timer_event_spec), (long)(created_timer_id))
192#define __sanitizer_syscall_post_timer_create( \ 192#define __sanitizer_syscall_post_timer_create( \
193 res, which_clock, timer_event_spec, created_timer_id) \ 193 res, which_clock, timer_event_spec, created_timer_id) \
194 __sanitizer_syscall_post_impl_timer_create(res, (long)(which_clock), \ 194 __sanitizer_syscall_post_impl_timer_create(res, (long)(which_clock), \
195 (long)(timer_event_spec), \ 195 (long)(timer_event_spec), \
196 (long)(created_timer_id)) 196 (long)(created_timer_id))
197#define __sanitizer_syscall_pre_timer_gettime(timer_id, setting) \ 197#define __sanitizer_syscall_pre_timer_gettime(timer_id, setting) \
198 __sanitizer_syscall_pre_impl_timer_gettime((long)(timer_id), (long)(setting)) 198 __sanitizer_syscall_pre_impl_timer_gettime((long)(timer_id), (long)(setting))
199#define __sanitizer_syscall_post_timer_gettime(res, timer_id, setting) \ 199#define __sanitizer_syscall_post_timer_gettime(res, timer_id, setting) \
200 __sanitizer_syscall_post_impl_timer_gettime(res, (long)(timer_id), \ 200 __sanitizer_syscall_post_impl_timer_gettime(res, (long)(timer_id), \
201 (long)(setting)) 201 (long)(setting))
202#define __sanitizer_syscall_pre_timer_getoverrun(timer_id) \ 202#define __sanitizer_syscall_pre_timer_getoverrun(timer_id) \
203 __sanitizer_syscall_pre_impl_timer_getoverrun((long)(timer_id)) 203 __sanitizer_syscall_pre_impl_timer_getoverrun((long)(timer_id))
204#define __sanitizer_syscall_post_timer_getoverrun(res, timer_id) \ 204#define __sanitizer_syscall_post_timer_getoverrun(res, timer_id) \
205 __sanitizer_syscall_post_impl_timer_getoverrun(res, (long)(timer_id)) 205 __sanitizer_syscall_post_impl_timer_getoverrun(res, (long)(timer_id))
206#define __sanitizer_syscall_pre_timer_settime(timer_id, flags, new_setting, \ 206#define __sanitizer_syscall_pre_timer_settime(timer_id, flags, new_setting, \
207 old_setting) \ 207 old_setting) \
208 __sanitizer_syscall_pre_impl_timer_settime((long)(timer_id), (long)(flags), \ 208 __sanitizer_syscall_pre_impl_timer_settime((long)(timer_id), (long)(flags), \
209 (long)(new_setting), \ 209 (long)(new_setting), \
210 (long)(old_setting)) 210 (long)(old_setting))
211#define __sanitizer_syscall_post_timer_settime(res, timer_id, flags, \ 211#define __sanitizer_syscall_post_timer_settime(res, timer_id, flags, \
212 new_setting, old_setting) \ 212 new_setting, old_setting) \
213 __sanitizer_syscall_post_impl_timer_settime( \ 213 __sanitizer_syscall_post_impl_timer_settime( \
214 res, (long)(timer_id), (long)(flags), (long)(new_setting), \ 214 res, (long)(timer_id), (long)(flags), (long)(new_setting), \
215 (long)(old_setting)) 215 (long)(old_setting))
216#define __sanitizer_syscall_pre_timer_delete(timer_id) \ 216#define __sanitizer_syscall_pre_timer_delete(timer_id) \
217 __sanitizer_syscall_pre_impl_timer_delete((long)(timer_id)) 217 __sanitizer_syscall_pre_impl_timer_delete((long)(timer_id))
218#define __sanitizer_syscall_post_timer_delete(res, timer_id) \ 218#define __sanitizer_syscall_post_timer_delete(res, timer_id) \
219 __sanitizer_syscall_post_impl_timer_delete(res, (long)(timer_id)) 219 __sanitizer_syscall_post_impl_timer_delete(res, (long)(timer_id))
220#define __sanitizer_syscall_pre_clock_settime(which_clock, tp) \ 220#define __sanitizer_syscall_pre_clock_settime(which_clock, tp) \
221 __sanitizer_syscall_pre_impl_clock_settime((long)(which_clock), (long)(tp)) 221 __sanitizer_syscall_pre_impl_clock_settime((long)(which_clock), (long)(tp))
222#define __sanitizer_syscall_post_clock_settime(res, which_clock, tp) \ 222#define __sanitizer_syscall_post_clock_settime(res, which_clock, tp) \
223 __sanitizer_syscall_post_impl_clock_settime(res, (long)(which_clock), \ 223 __sanitizer_syscall_post_impl_clock_settime(res, (long)(which_clock), \
224 (long)(tp)) 224 (long)(tp))
225#define __sanitizer_syscall_pre_clock_gettime(which_clock, tp) \ 225#define __sanitizer_syscall_pre_clock_gettime(which_clock, tp) \
226 __sanitizer_syscall_pre_impl_clock_gettime((long)(which_clock), (long)(tp)) 226 __sanitizer_syscall_pre_impl_clock_gettime((long)(which_clock), (long)(tp))
227#define __sanitizer_syscall_post_clock_gettime(res, which_clock, tp) \ 227#define __sanitizer_syscall_post_clock_gettime(res, which_clock, tp) \
228 __sanitizer_syscall_post_impl_clock_gettime(res, (long)(which_clock), \ 228 __sanitizer_syscall_post_impl_clock_gettime(res, (long)(which_clock), \
229 (long)(tp)) 229 (long)(tp))
230#define __sanitizer_syscall_pre_clock_adjtime(which_clock, tx) \ 230#define __sanitizer_syscall_pre_clock_adjtime(which_clock, tx) \
231 __sanitizer_syscall_pre_impl_clock_adjtime((long)(which_clock), (long)(tx)) 231 __sanitizer_syscall_pre_impl_clock_adjtime((long)(which_clock), (long)(tx))
232#define __sanitizer_syscall_post_clock_adjtime(res, which_clock, tx) \ 232#define __sanitizer_syscall_post_clock_adjtime(res, which_clock, tx) \
233 __sanitizer_syscall_post_impl_clock_adjtime(res, (long)(which_clock), \ 233 __sanitizer_syscall_post_impl_clock_adjtime(res, (long)(which_clock), \
234 (long)(tx)) 234 (long)(tx))
235#define __sanitizer_syscall_pre_clock_getres(which_clock, tp) \ 235#define __sanitizer_syscall_pre_clock_getres(which_clock, tp) \
236 __sanitizer_syscall_pre_impl_clock_getres((long)(which_clock), (long)(tp)) 236 __sanitizer_syscall_pre_impl_clock_getres((long)(which_clock), (long)(tp))
237#define __sanitizer_syscall_post_clock_getres(res, which_clock, tp) \ 237#define __sanitizer_syscall_post_clock_getres(res, which_clock, tp) \
238 __sanitizer_syscall_post_impl_clock_getres(res, (long)(which_clock), \ 238 __sanitizer_syscall_post_impl_clock_getres(res, (long)(which_clock), \
239 (long)(tp)) 239 (long)(tp))
240#define __sanitizer_syscall_pre_clock_nanosleep(which_clock, flags, rqtp, \ 240#define __sanitizer_syscall_pre_clock_nanosleep(which_clock, flags, rqtp, \
241 rmtp) \ 241 rmtp) \
242 __sanitizer_syscall_pre_impl_clock_nanosleep( \ 242 __sanitizer_syscall_pre_impl_clock_nanosleep( \
243 (long)(which_clock), (long)(flags), (long)(rqtp), (long)(rmtp)) 243 (long)(which_clock), (long)(flags), (long)(rqtp), (long)(rmtp))
244#define __sanitizer_syscall_post_clock_nanosleep(res, which_clock, flags, \ 244#define __sanitizer_syscall_post_clock_nanosleep(res, which_clock, flags, \
245 rqtp, rmtp) \ 245 rqtp, rmtp) \
246 __sanitizer_syscall_post_impl_clock_nanosleep( \ 246 __sanitizer_syscall_post_impl_clock_nanosleep( \
247 res, (long)(which_clock), (long)(flags), (long)(rqtp), (long)(rmtp)) 247 res, (long)(which_clock), (long)(flags), (long)(rqtp), (long)(rmtp))
248#define __sanitizer_syscall_pre_nice(increment) \ 248#define __sanitizer_syscall_pre_nice(increment) \
249 __sanitizer_syscall_pre_impl_nice((long)(increment)) 249 __sanitizer_syscall_pre_impl_nice((long)(increment))
250#define __sanitizer_syscall_post_nice(res, increment) \ 250#define __sanitizer_syscall_post_nice(res, increment) \
251 __sanitizer_syscall_post_impl_nice(res, (long)(increment)) 251 __sanitizer_syscall_post_impl_nice(res, (long)(increment))
252#define __sanitizer_syscall_pre_sched_setscheduler(pid, policy, param) \ 252#define __sanitizer_syscall_pre_sched_setscheduler(pid, policy, param) \
253 __sanitizer_syscall_pre_impl_sched_setscheduler((long)(pid), (long)(policy), \ 253 __sanitizer_syscall_pre_impl_sched_setscheduler((long)(pid), (long)(policy), \
254 (long)(param)) 254 (long)(param))
255#define __sanitizer_syscall_post_sched_setscheduler(res, pid, policy, param) \ 255#define __sanitizer_syscall_post_sched_setscheduler(res, pid, policy, param) \
256 __sanitizer_syscall_post_impl_sched_setscheduler( \ 256 __sanitizer_syscall_post_impl_sched_setscheduler( \
257 res, (long)(pid), (long)(policy), (long)(param)) 257 res, (long)(pid), (long)(policy), (long)(param))
258#define __sanitizer_syscall_pre_sched_setparam(pid, param) \ 258#define __sanitizer_syscall_pre_sched_setparam(pid, param) \
259 __sanitizer_syscall_pre_impl_sched_setparam((long)(pid), (long)(param)) 259 __sanitizer_syscall_pre_impl_sched_setparam((long)(pid), (long)(param))
260#define __sanitizer_syscall_post_sched_setparam(res, pid, param) \ 260#define __sanitizer_syscall_post_sched_setparam(res, pid, param) \
261 __sanitizer_syscall_post_impl_sched_setparam(res, (long)(pid), (long)(param)) 261 __sanitizer_syscall_post_impl_sched_setparam(res, (long)(pid), (long)(param))
262#define __sanitizer_syscall_pre_sched_getscheduler(pid) \ 262#define __sanitizer_syscall_pre_sched_getscheduler(pid) \
263 __sanitizer_syscall_pre_impl_sched_getscheduler((long)(pid)) 263 __sanitizer_syscall_pre_impl_sched_getscheduler((long)(pid))
264#define __sanitizer_syscall_post_sched_getscheduler(res, pid) \ 264#define __sanitizer_syscall_post_sched_getscheduler(res, pid) \
265 __sanitizer_syscall_post_impl_sched_getscheduler(res, (long)(pid)) 265 __sanitizer_syscall_post_impl_sched_getscheduler(res, (long)(pid))
266#define __sanitizer_syscall_pre_sched_getparam(pid, param) \ 266#define __sanitizer_syscall_pre_sched_getparam(pid, param) \
267 __sanitizer_syscall_pre_impl_sched_getparam((long)(pid), (long)(param)) 267 __sanitizer_syscall_pre_impl_sched_getparam((long)(pid), (long)(param))
268#define __sanitizer_syscall_post_sched_getparam(res, pid, param) \ 268#define __sanitizer_syscall_post_sched_getparam(res, pid, param) \
269 __sanitizer_syscall_post_impl_sched_getparam(res, (long)(pid), (long)(param)) 269 __sanitizer_syscall_post_impl_sched_getparam(res, (long)(pid), (long)(param))
270#define __sanitizer_syscall_pre_sched_setaffinity(pid, len, user_mask_ptr) \ 270#define __sanitizer_syscall_pre_sched_setaffinity(pid, len, user_mask_ptr) \
271 __sanitizer_syscall_pre_impl_sched_setaffinity((long)(pid), (long)(len), \ 271 __sanitizer_syscall_pre_impl_sched_setaffinity((long)(pid), (long)(len), \
272 (long)(user_mask_ptr)) 272 (long)(user_mask_ptr))
273#define __sanitizer_syscall_post_sched_setaffinity(res, pid, len, \ 273#define __sanitizer_syscall_post_sched_setaffinity(res, pid, len, \
274 user_mask_ptr) \ 274 user_mask_ptr) \
275 __sanitizer_syscall_post_impl_sched_setaffinity( \ 275 __sanitizer_syscall_post_impl_sched_setaffinity( \
276 res, (long)(pid), (long)(len), (long)(user_mask_ptr)) 276 res, (long)(pid), (long)(len), (long)(user_mask_ptr))
277#define __sanitizer_syscall_pre_sched_getaffinity(pid, len, user_mask_ptr) \ 277#define __sanitizer_syscall_pre_sched_getaffinity(pid, len, user_mask_ptr) \
278 __sanitizer_syscall_pre_impl_sched_getaffinity((long)(pid), (long)(len), \ 278 __sanitizer_syscall_pre_impl_sched_getaffinity((long)(pid), (long)(len), \
279 (long)(user_mask_ptr)) 279 (long)(user_mask_ptr))
280#define __sanitizer_syscall_post_sched_getaffinity(res, pid, len, \ 280#define __sanitizer_syscall_post_sched_getaffinity(res, pid, len, \
281 user_mask_ptr) \ 281 user_mask_ptr) \
282 __sanitizer_syscall_post_impl_sched_getaffinity( \ 282 __sanitizer_syscall_post_impl_sched_getaffinity( \
283 res, (long)(pid), (long)(len), (long)(user_mask_ptr)) 283 res, (long)(pid), (long)(len), (long)(user_mask_ptr))
284#define __sanitizer_syscall_pre_sched_yield() \ 284#define __sanitizer_syscall_pre_sched_yield() \
285 __sanitizer_syscall_pre_impl_sched_yield() 285 __sanitizer_syscall_pre_impl_sched_yield()
286#define __sanitizer_syscall_post_sched_yield(res) \ 286#define __sanitizer_syscall_post_sched_yield(res) \
287 __sanitizer_syscall_post_impl_sched_yield(res) 287 __sanitizer_syscall_post_impl_sched_yield(res)
288#define __sanitizer_syscall_pre_sched_get_priority_max(policy) \ 288#define __sanitizer_syscall_pre_sched_get_priority_max(policy) \
289 __sanitizer_syscall_pre_impl_sched_get_priority_max((long)(policy)) 289 __sanitizer_syscall_pre_impl_sched_get_priority_max((long)(policy))
290#define __sanitizer_syscall_post_sched_get_priority_max(res, policy) \ 290#define __sanitizer_syscall_post_sched_get_priority_max(res, policy) \
291 __sanitizer_syscall_post_impl_sched_get_priority_max(res, (long)(policy)) 291 __sanitizer_syscall_post_impl_sched_get_priority_max(res, (long)(policy))
292#define __sanitizer_syscall_pre_sched_get_priority_min(policy) \ 292#define __sanitizer_syscall_pre_sched_get_priority_min(policy) \
293 __sanitizer_syscall_pre_impl_sched_get_priority_min((long)(policy)) 293 __sanitizer_syscall_pre_impl_sched_get_priority_min((long)(policy))
294#define __sanitizer_syscall_post_sched_get_priority_min(res, policy) \ 294#define __sanitizer_syscall_post_sched_get_priority_min(res, policy) \
295 __sanitizer_syscall_post_impl_sched_get_priority_min(res, (long)(policy)) 295 __sanitizer_syscall_post_impl_sched_get_priority_min(res, (long)(policy))
296#define __sanitizer_syscall_pre_sched_rr_get_interval(pid, interval) \ 296#define __sanitizer_syscall_pre_sched_rr_get_interval(pid, interval) \
297 __sanitizer_syscall_pre_impl_sched_rr_get_interval((long)(pid), \ 297 __sanitizer_syscall_pre_impl_sched_rr_get_interval((long)(pid), \
298 (long)(interval)) 298 (long)(interval))
299#define __sanitizer_syscall_post_sched_rr_get_interval(res, pid, interval) \ 299#define __sanitizer_syscall_post_sched_rr_get_interval(res, pid, interval) \
300 __sanitizer_syscall_post_impl_sched_rr_get_interval(res, (long)(pid), \ 300 __sanitizer_syscall_post_impl_sched_rr_get_interval(res, (long)(pid), \
301 (long)(interval)) 301 (long)(interval))
302#define __sanitizer_syscall_pre_setpriority(which, who, niceval) \ 302#define __sanitizer_syscall_pre_setpriority(which, who, niceval) \
303 __sanitizer_syscall_pre_impl_setpriority((long)(which), (long)(who), \ 303 __sanitizer_syscall_pre_impl_setpriority((long)(which), (long)(who), \
304 (long)(niceval)) 304 (long)(niceval))
305#define __sanitizer_syscall_post_setpriority(res, which, who, niceval) \ 305#define __sanitizer_syscall_post_setpriority(res, which, who, niceval) \
306 __sanitizer_syscall_post_impl_setpriority(res, (long)(which), (long)(who), \ 306 __sanitizer_syscall_post_impl_setpriority(res, (long)(which), (long)(who), \
307 (long)(niceval)) 307 (long)(niceval))
308#define __sanitizer_syscall_pre_getpriority(which, who) \ 308#define __sanitizer_syscall_pre_getpriority(which, who) \
309 __sanitizer_syscall_pre_impl_getpriority((long)(which), (long)(who)) 309 __sanitizer_syscall_pre_impl_getpriority((long)(which), (long)(who))
310#define __sanitizer_syscall_post_getpriority(res, which, who) \ 310#define __sanitizer_syscall_post_getpriority(res, which, who) \
311 __sanitizer_syscall_post_impl_getpriority(res, (long)(which), (long)(who)) 311 __sanitizer_syscall_post_impl_getpriority(res, (long)(which), (long)(who))
312#define __sanitizer_syscall_pre_shutdown(arg0, arg1) \ 312#define __sanitizer_syscall_pre_shutdown(arg0, arg1) \
313 __sanitizer_syscall_pre_impl_shutdown((long)(arg0), (long)(arg1)) 313 __sanitizer_syscall_pre_impl_shutdown((long)(arg0), (long)(arg1))
314#define __sanitizer_syscall_post_shutdown(res, arg0, arg1) \ 314#define __sanitizer_syscall_post_shutdown(res, arg0, arg1) \
315 __sanitizer_syscall_post_impl_shutdown(res, (long)(arg0), (long)(arg1)) 315 __sanitizer_syscall_post_impl_shutdown(res, (long)(arg0), (long)(arg1))
316#define __sanitizer_syscall_pre_reboot(magic1, magic2, cmd, arg) \ 316#define __sanitizer_syscall_pre_reboot(magic1, magic2, cmd, arg) \
317 __sanitizer_syscall_pre_impl_reboot((long)(magic1), (long)(magic2), \ 317 __sanitizer_syscall_pre_impl_reboot((long)(magic1), (long)(magic2), \
318 (long)(cmd), (long)(arg)) 318 (long)(cmd), (long)(arg))
319#define __sanitizer_syscall_post_reboot(res, magic1, magic2, cmd, arg) \ 319#define __sanitizer_syscall_post_reboot(res, magic1, magic2, cmd, arg) \
320 __sanitizer_syscall_post_impl_reboot(res, (long)(magic1), (long)(magic2), \ 320 __sanitizer_syscall_post_impl_reboot(res, (long)(magic1), (long)(magic2), \
321 (long)(cmd), (long)(arg)) 321 (long)(cmd), (long)(arg))
322#define __sanitizer_syscall_pre_restart_syscall() \ 322#define __sanitizer_syscall_pre_restart_syscall() \
323 __sanitizer_syscall_pre_impl_restart_syscall() 323 __sanitizer_syscall_pre_impl_restart_syscall()
324#define __sanitizer_syscall_post_restart_syscall(res) \ 324#define __sanitizer_syscall_post_restart_syscall(res) \
325 __sanitizer_syscall_post_impl_restart_syscall(res) 325 __sanitizer_syscall_post_impl_restart_syscall(res)
326#define __sanitizer_syscall_pre_kexec_load(entry, nr_segments, segments, \ 326#define __sanitizer_syscall_pre_kexec_load(entry, nr_segments, segments, \
327 flags) \ 327 flags) \
328 __sanitizer_syscall_pre_impl_kexec_load((long)(entry), (long)(nr_segments), \ 328 __sanitizer_syscall_pre_impl_kexec_load((long)(entry), (long)(nr_segments), \
329 (long)(segments), (long)(flags)) 329 (long)(segments), (long)(flags))
330#define __sanitizer_syscall_post_kexec_load(res, entry, nr_segments, segments, \ 330#define __sanitizer_syscall_post_kexec_load(res, entry, nr_segments, segments, \
331 flags) \ 331 flags) \
332 __sanitizer_syscall_post_impl_kexec_load(res, (long)(entry), \ 332 __sanitizer_syscall_post_impl_kexec_load(res, (long)(entry), \
333 (long)(nr_segments), \ 333 (long)(nr_segments), \
334 (long)(segments), (long)(flags)) 334 (long)(segments), (long)(flags))
335#define __sanitizer_syscall_pre_exit(error_code) \ 335#define __sanitizer_syscall_pre_exit(error_code) \
336 __sanitizer_syscall_pre_impl_exit((long)(error_code)) 336 __sanitizer_syscall_pre_impl_exit((long)(error_code))
337#define __sanitizer_syscall_post_exit(res, error_code) \ 337#define __sanitizer_syscall_post_exit(res, error_code) \
338 __sanitizer_syscall_post_impl_exit(res, (long)(error_code)) 338 __sanitizer_syscall_post_impl_exit(res, (long)(error_code))
339#define __sanitizer_syscall_pre_exit_group(error_code) \ 339#define __sanitizer_syscall_pre_exit_group(error_code) \
340 __sanitizer_syscall_pre_impl_exit_group((long)(error_code)) 340 __sanitizer_syscall_pre_impl_exit_group((long)(error_code))
341#define __sanitizer_syscall_post_exit_group(res, error_code) \ 341#define __sanitizer_syscall_post_exit_group(res, error_code) \
342 __sanitizer_syscall_post_impl_exit_group(res, (long)(error_code)) 342 __sanitizer_syscall_post_impl_exit_group(res, (long)(error_code))
343#define __sanitizer_syscall_pre_wait4(pid, stat_addr, options, ru) \ 343#define __sanitizer_syscall_pre_wait4(pid, stat_addr, options, ru) \
344 __sanitizer_syscall_pre_impl_wait4((long)(pid), (long)(stat_addr), \ 344 __sanitizer_syscall_pre_impl_wait4((long)(pid), (long)(stat_addr), \
345 (long)(options), (long)(ru)) 345 (long)(options), (long)(ru))
346#define __sanitizer_syscall_post_wait4(res, pid, stat_addr, options, ru) \ 346#define __sanitizer_syscall_post_wait4(res, pid, stat_addr, options, ru) \
347 __sanitizer_syscall_post_impl_wait4(res, (long)(pid), (long)(stat_addr), \ 347 __sanitizer_syscall_post_impl_wait4(res, (long)(pid), (long)(stat_addr), \
348 (long)(options), (long)(ru)) 348 (long)(options), (long)(ru))
349#define __sanitizer_syscall_pre_waitid(which, pid, infop, options, ru) \ 349#define __sanitizer_syscall_pre_waitid(which, pid, infop, options, ru) \
350 __sanitizer_syscall_pre_impl_waitid( \ 350 __sanitizer_syscall_pre_impl_waitid( \
351 (long)(which), (long)(pid), (long)(infop), (long)(options), (long)(ru)) 351 (long)(which), (long)(pid), (long)(infop), (long)(options), (long)(ru))
352#define __sanitizer_syscall_post_waitid(res, which, pid, infop, options, ru) \ 352#define __sanitizer_syscall_post_waitid(res, which, pid, infop, options, ru) \
353 __sanitizer_syscall_post_impl_waitid(res, (long)(which), (long)(pid), \ 353 __sanitizer_syscall_post_impl_waitid(res, (long)(which), (long)(pid), \
354 (long)(infop), (long)(options), \ 354 (long)(infop), (long)(options), \
355 (long)(ru)) 355 (long)(ru))
356#define __sanitizer_syscall_pre_waitpid(pid, stat_addr, options) \ 356#define __sanitizer_syscall_pre_waitpid(pid, stat_addr, options) \
357 __sanitizer_syscall_pre_impl_waitpid((long)(pid), (long)(stat_addr), \ 357 __sanitizer_syscall_pre_impl_waitpid((long)(pid), (long)(stat_addr), \
358 (long)(options)) 358 (long)(options))
359#define __sanitizer_syscall_post_waitpid(res, pid, stat_addr, options) \ 359#define __sanitizer_syscall_post_waitpid(res, pid, stat_addr, options) \
360 __sanitizer_syscall_post_impl_waitpid(res, (long)(pid), (long)(stat_addr), \ 360 __sanitizer_syscall_post_impl_waitpid(res, (long)(pid), (long)(stat_addr), \
361 (long)(options)) 361 (long)(options))
362#define __sanitizer_syscall_pre_set_tid_address(tidptr) \ 362#define __sanitizer_syscall_pre_set_tid_address(tidptr) \
363 __sanitizer_syscall_pre_impl_set_tid_address((long)(tidptr)) 363 __sanitizer_syscall_pre_impl_set_tid_address((long)(tidptr))
364#define __sanitizer_syscall_post_set_tid_address(res, tidptr) \ 364#define __sanitizer_syscall_post_set_tid_address(res, tidptr) \
365 __sanitizer_syscall_post_impl_set_tid_address(res, (long)(tidptr)) 365 __sanitizer_syscall_post_impl_set_tid_address(res, (long)(tidptr))
366#define __sanitizer_syscall_pre_init_module(umod, len, uargs) \ 366#define __sanitizer_syscall_pre_init_module(umod, len, uargs) \
367 __sanitizer_syscall_pre_impl_init_module((long)(umod), (long)(len), \ 367 __sanitizer_syscall_pre_impl_init_module((long)(umod), (long)(len), \
368 (long)(uargs)) 368 (long)(uargs))
369#define __sanitizer_syscall_post_init_module(res, umod, len, uargs) \ 369#define __sanitizer_syscall_post_init_module(res, umod, len, uargs) \
370 __sanitizer_syscall_post_impl_init_module(res, (long)(umod), (long)(len), \ 370 __sanitizer_syscall_post_impl_init_module(res, (long)(umod), (long)(len), \
371 (long)(uargs)) 371 (long)(uargs))
372#define __sanitizer_syscall_pre_delete_module(name_user, flags) \ 372#define __sanitizer_syscall_pre_delete_module(name_user, flags) \
373 __sanitizer_syscall_pre_impl_delete_module((long)(name_user), (long)(flags)) 373 __sanitizer_syscall_pre_impl_delete_module((long)(name_user), (long)(flags))
374#define __sanitizer_syscall_post_delete_module(res, name_user, flags) \ 374#define __sanitizer_syscall_post_delete_module(res, name_user, flags) \
375 __sanitizer_syscall_post_impl_delete_module(res, (long)(name_user), \ 375 __sanitizer_syscall_post_impl_delete_module(res, (long)(name_user), \
376 (long)(flags)) 376 (long)(flags))
377#define __sanitizer_syscall_pre_rt_sigprocmask(how, set, oset, sigsetsize) \ 377#define __sanitizer_syscall_pre_rt_sigprocmask(how, set, oset, sigsetsize) \
378 __sanitizer_syscall_pre_impl_rt_sigprocmask( \ 378 __sanitizer_syscall_pre_impl_rt_sigprocmask( \
379 (long)(how), (long)(set), (long)(oset), (long)(sigsetsize)) 379 (long)(how), (long)(set), (long)(oset), (long)(sigsetsize))
380#define __sanitizer_syscall_post_rt_sigprocmask(res, how, set, oset, \ 380#define __sanitizer_syscall_post_rt_sigprocmask(res, how, set, oset, \
381 sigsetsize) \ 381 sigsetsize) \
382 __sanitizer_syscall_post_impl_rt_sigprocmask( \ 382 __sanitizer_syscall_post_impl_rt_sigprocmask( \
383 res, (long)(how), (long)(set), (long)(oset), (long)(sigsetsize)) 383 res, (long)(how), (long)(set), (long)(oset), (long)(sigsetsize))
384#define __sanitizer_syscall_pre_rt_sigpending(set, sigsetsize) \ 384#define __sanitizer_syscall_pre_rt_sigpending(set, sigsetsize) \
385 __sanitizer_syscall_pre_impl_rt_sigpending((long)(set), (long)(sigsetsize)) 385 __sanitizer_syscall_pre_impl_rt_sigpending((long)(set), (long)(sigsetsize))
386#define __sanitizer_syscall_post_rt_sigpending(res, set, sigsetsize) \ 386#define __sanitizer_syscall_post_rt_sigpending(res, set, sigsetsize) \
387 __sanitizer_syscall_post_impl_rt_sigpending(res, (long)(set), \ 387 __sanitizer_syscall_post_impl_rt_sigpending(res, (long)(set), \
388 (long)(sigsetsize)) 388 (long)(sigsetsize))
389#define __sanitizer_syscall_pre_rt_sigtimedwait(uthese, uinfo, uts, \ 389#define __sanitizer_syscall_pre_rt_sigtimedwait(uthese, uinfo, uts, \
390 sigsetsize) \ 390 sigsetsize) \
391 __sanitizer_syscall_pre_impl_rt_sigtimedwait( \ 391 __sanitizer_syscall_pre_impl_rt_sigtimedwait( \
392 (long)(uthese), (long)(uinfo), (long)(uts), (long)(sigsetsize)) 392 (long)(uthese), (long)(uinfo), (long)(uts), (long)(sigsetsize))
393#define __sanitizer_syscall_post_rt_sigtimedwait(res, uthese, uinfo, uts, \ 393#define __sanitizer_syscall_post_rt_sigtimedwait(res, uthese, uinfo, uts, \
394 sigsetsize) \ 394 sigsetsize) \
395 __sanitizer_syscall_post_impl_rt_sigtimedwait( \ 395 __sanitizer_syscall_post_impl_rt_sigtimedwait( \
396 res, (long)(uthese), (long)(uinfo), (long)(uts), (long)(sigsetsize)) 396 res, (long)(uthese), (long)(uinfo), (long)(uts), (long)(sigsetsize))
397#define __sanitizer_syscall_pre_rt_tgsigqueueinfo(tgid, pid, sig, uinfo) \ 397#define __sanitizer_syscall_pre_rt_tgsigqueueinfo(tgid, pid, sig, uinfo) \
398 __sanitizer_syscall_pre_impl_rt_tgsigqueueinfo((long)(tgid), (long)(pid), \ 398 __sanitizer_syscall_pre_impl_rt_tgsigqueueinfo((long)(tgid), (long)(pid), \
399 (long)(sig), (long)(uinfo)) 399 (long)(sig), (long)(uinfo))
400#define __sanitizer_syscall_post_rt_tgsigqueueinfo(res, tgid, pid, sig, uinfo) \ 400#define __sanitizer_syscall_post_rt_tgsigqueueinfo(res, tgid, pid, sig, uinfo) \
401 __sanitizer_syscall_post_impl_rt_tgsigqueueinfo( \ 401 __sanitizer_syscall_post_impl_rt_tgsigqueueinfo( \
402 res, (long)(tgid), (long)(pid), (long)(sig), (long)(uinfo)) 402 res, (long)(tgid), (long)(pid), (long)(sig), (long)(uinfo))
403#define __sanitizer_syscall_pre_kill(pid, sig) \ 403#define __sanitizer_syscall_pre_kill(pid, sig) \
404 __sanitizer_syscall_pre_impl_kill((long)(pid), (long)(sig)) 404 __sanitizer_syscall_pre_impl_kill((long)(pid), (long)(sig))
405#define __sanitizer_syscall_post_kill(res, pid, sig) \ 405#define __sanitizer_syscall_post_kill(res, pid, sig) \
406 __sanitizer_syscall_post_impl_kill(res, (long)(pid), (long)(sig)) 406 __sanitizer_syscall_post_impl_kill(res, (long)(pid), (long)(sig))
407#define __sanitizer_syscall_pre_tgkill(tgid, pid, sig) \ 407#define __sanitizer_syscall_pre_tgkill(tgid, pid, sig) \
408 __sanitizer_syscall_pre_impl_tgkill((long)(tgid), (long)(pid), (long)(sig)) 408 __sanitizer_syscall_pre_impl_tgkill((long)(tgid), (long)(pid), (long)(sig))
409#define __sanitizer_syscall_post_tgkill(res, tgid, pid, sig) \ 409#define __sanitizer_syscall_post_tgkill(res, tgid, pid, sig) \
410 __sanitizer_syscall_post_impl_tgkill(res, (long)(tgid), (long)(pid), \ 410 __sanitizer_syscall_post_impl_tgkill(res, (long)(tgid), (long)(pid), \
411 (long)(sig)) 411 (long)(sig))
412#define __sanitizer_syscall_pre_tkill(pid, sig) \ 412#define __sanitizer_syscall_pre_tkill(pid, sig) \
413 __sanitizer_syscall_pre_impl_tkill((long)(pid), (long)(sig)) 413 __sanitizer_syscall_pre_impl_tkill((long)(pid), (long)(sig))
414#define __sanitizer_syscall_post_tkill(res, pid, sig) \ 414#define __sanitizer_syscall_post_tkill(res, pid, sig) \
415 __sanitizer_syscall_post_impl_tkill(res, (long)(pid), (long)(sig)) 415 __sanitizer_syscall_post_impl_tkill(res, (long)(pid), (long)(sig))
416#define __sanitizer_syscall_pre_rt_sigqueueinfo(pid, sig, uinfo) \ 416#define __sanitizer_syscall_pre_rt_sigqueueinfo(pid, sig, uinfo) \
417 __sanitizer_syscall_pre_impl_rt_sigqueueinfo((long)(pid), (long)(sig), \ 417 __sanitizer_syscall_pre_impl_rt_sigqueueinfo((long)(pid), (long)(sig), \
418 (long)(uinfo)) 418 (long)(uinfo))
419#define __sanitizer_syscall_post_rt_sigqueueinfo(res, pid, sig, uinfo) \ 419#define __sanitizer_syscall_post_rt_sigqueueinfo(res, pid, sig, uinfo) \
420 __sanitizer_syscall_post_impl_rt_sigqueueinfo(res, (long)(pid), (long)(sig), \ 420 __sanitizer_syscall_post_impl_rt_sigqueueinfo(res, (long)(pid), (long)(sig), \
421 (long)(uinfo)) 421 (long)(uinfo))
422#define __sanitizer_syscall_pre_sgetmask() \ 422#define __sanitizer_syscall_pre_sgetmask() \
423 __sanitizer_syscall_pre_impl_sgetmask() 423 __sanitizer_syscall_pre_impl_sgetmask()
424#define __sanitizer_syscall_post_sgetmask(res) \ 424#define __sanitizer_syscall_post_sgetmask(res) \
425 __sanitizer_syscall_post_impl_sgetmask(res) 425 __sanitizer_syscall_post_impl_sgetmask(res)
426#define __sanitizer_syscall_pre_ssetmask(newmask) \ 426#define __sanitizer_syscall_pre_ssetmask(newmask) \
427 __sanitizer_syscall_pre_impl_ssetmask((long)(newmask)) 427 __sanitizer_syscall_pre_impl_ssetmask((long)(newmask))
428#define __sanitizer_syscall_post_ssetmask(res, newmask) \ 428#define __sanitizer_syscall_post_ssetmask(res, newmask) \
429 __sanitizer_syscall_post_impl_ssetmask(res, (long)(newmask)) 429 __sanitizer_syscall_post_impl_ssetmask(res, (long)(newmask))
430#define __sanitizer_syscall_pre_signal(sig, handler) \ 430#define __sanitizer_syscall_pre_signal(sig, handler) \
431 __sanitizer_syscall_pre_impl_signal((long)(sig), (long)(handler)) 431 __sanitizer_syscall_pre_impl_signal((long)(sig), (long)(handler))
432#define __sanitizer_syscall_post_signal(res, sig, handler) \ 432#define __sanitizer_syscall_post_signal(res, sig, handler) \
433 __sanitizer_syscall_post_impl_signal(res, (long)(sig), (long)(handler)) 433 __sanitizer_syscall_post_impl_signal(res, (long)(sig), (long)(handler))
434#define __sanitizer_syscall_pre_pause() __sanitizer_syscall_pre_impl_pause() 434#define __sanitizer_syscall_pre_pause() __sanitizer_syscall_pre_impl_pause()
435#define __sanitizer_syscall_post_pause(res) \ 435#define __sanitizer_syscall_post_pause(res) \
436 __sanitizer_syscall_post_impl_pause(res) 436 __sanitizer_syscall_post_impl_pause(res)
437#define __sanitizer_syscall_pre_sync() __sanitizer_syscall_pre_impl_sync() 437#define __sanitizer_syscall_pre_sync() __sanitizer_syscall_pre_impl_sync()
438#define __sanitizer_syscall_post_sync(res) \ 438#define __sanitizer_syscall_post_sync(res) \
439 __sanitizer_syscall_post_impl_sync(res) 439 __sanitizer_syscall_post_impl_sync(res)
440#define __sanitizer_syscall_pre_fsync(fd) \ 440#define __sanitizer_syscall_pre_fsync(fd) \
441 __sanitizer_syscall_pre_impl_fsync((long)(fd)) 441 __sanitizer_syscall_pre_impl_fsync((long)(fd))
442#define __sanitizer_syscall_post_fsync(res, fd) \ 442#define __sanitizer_syscall_post_fsync(res, fd) \
443 __sanitizer_syscall_post_impl_fsync(res, (long)(fd)) 443 __sanitizer_syscall_post_impl_fsync(res, (long)(fd))
444#define __sanitizer_syscall_pre_fdatasync(fd) \ 444#define __sanitizer_syscall_pre_fdatasync(fd) \
445 __sanitizer_syscall_pre_impl_fdatasync((long)(fd)) 445 __sanitizer_syscall_pre_impl_fdatasync((long)(fd))
446#define __sanitizer_syscall_post_fdatasync(res, fd) \ 446#define __sanitizer_syscall_post_fdatasync(res, fd) \
447 __sanitizer_syscall_post_impl_fdatasync(res, (long)(fd)) 447 __sanitizer_syscall_post_impl_fdatasync(res, (long)(fd))
448#define __sanitizer_syscall_pre_bdflush(func, data) \ 448#define __sanitizer_syscall_pre_bdflush(func, data) \
449 __sanitizer_syscall_pre_impl_bdflush((long)(func), (long)(data)) 449 __sanitizer_syscall_pre_impl_bdflush((long)(func), (long)(data))
450#define __sanitizer_syscall_post_bdflush(res, func, data) \ 450#define __sanitizer_syscall_post_bdflush(res, func, data) \
451 __sanitizer_syscall_post_impl_bdflush(res, (long)(func), (long)(data)) 451 __sanitizer_syscall_post_impl_bdflush(res, (long)(func), (long)(data))
452#define __sanitizer_syscall_pre_mount(dev_name, dir_name, type, flags, data) \ 452#define __sanitizer_syscall_pre_mount(dev_name, dir_name, type, flags, data) \
453 __sanitizer_syscall_pre_impl_mount((long)(dev_name), (long)(dir_name), \ 453 __sanitizer_syscall_pre_impl_mount((long)(dev_name), (long)(dir_name), \
454 (long)(type), (long)(flags), \ 454 (long)(type), (long)(flags), \
455 (long)(data)) 455 (long)(data))
456#define __sanitizer_syscall_post_mount(res, dev_name, dir_name, type, flags, \ 456#define __sanitizer_syscall_post_mount(res, dev_name, dir_name, type, flags, \
457 data) \ 457 data) \
458 __sanitizer_syscall_post_impl_mount(res, (long)(dev_name), (long)(dir_name), \ 458 __sanitizer_syscall_post_impl_mount(res, (long)(dev_name), (long)(dir_name), \
459 (long)(type), (long)(flags), \ 459 (long)(type), (long)(flags), \
460 (long)(data)) 460 (long)(data))
461#define __sanitizer_syscall_pre_umount(name, flags) \ 461#define __sanitizer_syscall_pre_umount(name, flags) \
462 __sanitizer_syscall_pre_impl_umount((long)(name), (long)(flags)) 462 __sanitizer_syscall_pre_impl_umount((long)(name), (long)(flags))
463#define __sanitizer_syscall_post_umount(res, name, flags) \ 463#define __sanitizer_syscall_post_umount(res, name, flags) \
464 __sanitizer_syscall_post_impl_umount(res, (long)(name), (long)(flags)) 464 __sanitizer_syscall_post_impl_umount(res, (long)(name), (long)(flags))
465#define __sanitizer_syscall_pre_oldumount(name) \ 465#define __sanitizer_syscall_pre_oldumount(name) \
466 __sanitizer_syscall_pre_impl_oldumount((long)(name)) 466 __sanitizer_syscall_pre_impl_oldumount((long)(name))
467#define __sanitizer_syscall_post_oldumount(res, name) \ 467#define __sanitizer_syscall_post_oldumount(res, name) \
468 __sanitizer_syscall_post_impl_oldumount(res, (long)(name)) 468 __sanitizer_syscall_post_impl_oldumount(res, (long)(name))
469#define __sanitizer_syscall_pre_truncate(path, length) \ 469#define __sanitizer_syscall_pre_truncate(path, length) \
470 __sanitizer_syscall_pre_impl_truncate((long)(path), (long)(length)) 470 __sanitizer_syscall_pre_impl_truncate((long)(path), (long)(length))
471#define __sanitizer_syscall_post_truncate(res, path, length) \ 471#define __sanitizer_syscall_post_truncate(res, path, length) \
472 __sanitizer_syscall_post_impl_truncate(res, (long)(path), (long)(length)) 472 __sanitizer_syscall_post_impl_truncate(res, (long)(path), (long)(length))
473#define __sanitizer_syscall_pre_ftruncate(fd, length) \ 473#define __sanitizer_syscall_pre_ftruncate(fd, length) \
474 __sanitizer_syscall_pre_impl_ftruncate((long)(fd), (long)(length)) 474 __sanitizer_syscall_pre_impl_ftruncate((long)(fd), (long)(length))
475#define __sanitizer_syscall_post_ftruncate(res, fd, length) \ 475#define __sanitizer_syscall_post_ftruncate(res, fd, length) \
476 __sanitizer_syscall_post_impl_ftruncate(res, (long)(fd), (long)(length)) 476 __sanitizer_syscall_post_impl_ftruncate(res, (long)(fd), (long)(length))
477#define __sanitizer_syscall_pre_stat(filename, statbuf) \ 477#define __sanitizer_syscall_pre_stat(filename, statbuf) \
478 __sanitizer_syscall_pre_impl_stat((long)(filename), (long)(statbuf)) 478 __sanitizer_syscall_pre_impl_stat((long)(filename), (long)(statbuf))
479#define __sanitizer_syscall_post_stat(res, filename, statbuf) \ 479#define __sanitizer_syscall_post_stat(res, filename, statbuf) \
480 __sanitizer_syscall_post_impl_stat(res, (long)(filename), (long)(statbuf)) 480 __sanitizer_syscall_post_impl_stat(res, (long)(filename), (long)(statbuf))
481#define __sanitizer_syscall_pre_statfs(path, buf) \ 481#define __sanitizer_syscall_pre_statfs(path, buf) \
482 __sanitizer_syscall_pre_impl_statfs((long)(path), (long)(buf)) 482 __sanitizer_syscall_pre_impl_statfs((long)(path), (long)(buf))
483#define __sanitizer_syscall_post_statfs(res, path, buf) \ 483#define __sanitizer_syscall_post_statfs(res, path, buf) \
484 __sanitizer_syscall_post_impl_statfs(res, (long)(path), (long)(buf)) 484 __sanitizer_syscall_post_impl_statfs(res, (long)(path), (long)(buf))
485#define __sanitizer_syscall_pre_statfs64(path, sz, buf) \ 485#define __sanitizer_syscall_pre_statfs64(path, sz, buf) \
486 __sanitizer_syscall_pre_impl_statfs64((long)(path), (long)(sz), (long)(buf)) 486 __sanitizer_syscall_pre_impl_statfs64((long)(path), (long)(sz), (long)(buf))
487#define __sanitizer_syscall_post_statfs64(res, path, sz, buf) \ 487#define __sanitizer_syscall_post_statfs64(res, path, sz, buf) \
488 __sanitizer_syscall_post_impl_statfs64(res, (long)(path), (long)(sz), \ 488 __sanitizer_syscall_post_impl_statfs64(res, (long)(path), (long)(sz), \
489 (long)(buf)) 489 (long)(buf))
490#define __sanitizer_syscall_pre_fstatfs(fd, buf) \ 490#define __sanitizer_syscall_pre_fstatfs(fd, buf) \
491 __sanitizer_syscall_pre_impl_fstatfs((long)(fd), (long)(buf)) 491 __sanitizer_syscall_pre_impl_fstatfs((long)(fd), (long)(buf))
492#define __sanitizer_syscall_post_fstatfs(res, fd, buf) \ 492#define __sanitizer_syscall_post_fstatfs(res, fd, buf) \
493 __sanitizer_syscall_post_impl_fstatfs(res, (long)(fd), (long)(buf)) 493 __sanitizer_syscall_post_impl_fstatfs(res, (long)(fd), (long)(buf))
494#define __sanitizer_syscall_pre_fstatfs64(fd, sz, buf) \ 494#define __sanitizer_syscall_pre_fstatfs64(fd, sz, buf) \
495 __sanitizer_syscall_pre_impl_fstatfs64((long)(fd), (long)(sz), (long)(buf)) 495 __sanitizer_syscall_pre_impl_fstatfs64((long)(fd), (long)(sz), (long)(buf))
496#define __sanitizer_syscall_post_fstatfs64(res, fd, sz, buf) \ 496#define __sanitizer_syscall_post_fstatfs64(res, fd, sz, buf) \
497 __sanitizer_syscall_post_impl_fstatfs64(res, (long)(fd), (long)(sz), \ 497 __sanitizer_syscall_post_impl_fstatfs64(res, (long)(fd), (long)(sz), \
498 (long)(buf)) 498 (long)(buf))
499#define __sanitizer_syscall_pre_lstat(filename, statbuf) \ 499#define __sanitizer_syscall_pre_lstat(filename, statbuf) \
500 __sanitizer_syscall_pre_impl_lstat((long)(filename), (long)(statbuf)) 500 __sanitizer_syscall_pre_impl_lstat((long)(filename), (long)(statbuf))
501#define __sanitizer_syscall_post_lstat(res, filename, statbuf) \ 501#define __sanitizer_syscall_post_lstat(res, filename, statbuf) \
502 __sanitizer_syscall_post_impl_lstat(res, (long)(filename), (long)(statbuf)) 502 __sanitizer_syscall_post_impl_lstat(res, (long)(filename), (long)(statbuf))
503#define __sanitizer_syscall_pre_fstat(fd, statbuf) \ 503#define __sanitizer_syscall_pre_fstat(fd, statbuf) \
504 __sanitizer_syscall_pre_impl_fstat((long)(fd), (long)(statbuf)) 504 __sanitizer_syscall_pre_impl_fstat((long)(fd), (long)(statbuf))
505#define __sanitizer_syscall_post_fstat(res, fd, statbuf) \ 505#define __sanitizer_syscall_post_fstat(res, fd, statbuf) \
506 __sanitizer_syscall_post_impl_fstat(res, (long)(fd), (long)(statbuf)) 506 __sanitizer_syscall_post_impl_fstat(res, (long)(fd), (long)(statbuf))
507#define __sanitizer_syscall_pre_newstat(filename, statbuf) \ 507#define __sanitizer_syscall_pre_newstat(filename, statbuf) \
508 __sanitizer_syscall_pre_impl_newstat((long)(filename), (long)(statbuf)) 508 __sanitizer_syscall_pre_impl_newstat((long)(filename), (long)(statbuf))
509#define __sanitizer_syscall_post_newstat(res, filename, statbuf) \ 509#define __sanitizer_syscall_post_newstat(res, filename, statbuf) \
510 __sanitizer_syscall_post_impl_newstat(res, (long)(filename), (long)(statbuf)) 510 __sanitizer_syscall_post_impl_newstat(res, (long)(filename), (long)(statbuf))
511#define __sanitizer_syscall_pre_newlstat(filename, statbuf) \ 511#define __sanitizer_syscall_pre_newlstat(filename, statbuf) \
512 __sanitizer_syscall_pre_impl_newlstat((long)(filename), (long)(statbuf)) 512 __sanitizer_syscall_pre_impl_newlstat((long)(filename), (long)(statbuf))
513#define __sanitizer_syscall_post_newlstat(res, filename, statbuf) \ 513#define __sanitizer_syscall_post_newlstat(res, filename, statbuf) \
514 __sanitizer_syscall_post_impl_newlstat(res, (long)(filename), (long)(statbuf)) 514 __sanitizer_syscall_post_impl_newlstat(res, (long)(filename), (long)(statbuf))
515#define __sanitizer_syscall_pre_newfstat(fd, statbuf) \ 515#define __sanitizer_syscall_pre_newfstat(fd, statbuf) \
516 __sanitizer_syscall_pre_impl_newfstat((long)(fd), (long)(statbuf)) 516 __sanitizer_syscall_pre_impl_newfstat((long)(fd), (long)(statbuf))
517#define __sanitizer_syscall_post_newfstat(res, fd, statbuf) \ 517#define __sanitizer_syscall_post_newfstat(res, fd, statbuf) \
518 __sanitizer_syscall_post_impl_newfstat(res, (long)(fd), (long)(statbuf)) 518 __sanitizer_syscall_post_impl_newfstat(res, (long)(fd), (long)(statbuf))
519#define __sanitizer_syscall_pre_ustat(dev, ubuf) \ 519#define __sanitizer_syscall_pre_ustat(dev, ubuf) \
520 __sanitizer_syscall_pre_impl_ustat((long)(dev), (long)(ubuf)) 520 __sanitizer_syscall_pre_impl_ustat((long)(dev), (long)(ubuf))
521#define __sanitizer_syscall_post_ustat(res, dev, ubuf) \ 521#define __sanitizer_syscall_post_ustat(res, dev, ubuf) \
522 __sanitizer_syscall_post_impl_ustat(res, (long)(dev), (long)(ubuf)) 522 __sanitizer_syscall_post_impl_ustat(res, (long)(dev), (long)(ubuf))
523#define __sanitizer_syscall_pre_stat64(filename, statbuf) \ 523#define __sanitizer_syscall_pre_stat64(filename, statbuf) \
524 __sanitizer_syscall_pre_impl_stat64((long)(filename), (long)(statbuf)) 524 __sanitizer_syscall_pre_impl_stat64((long)(filename), (long)(statbuf))
525#define __sanitizer_syscall_post_stat64(res, filename, statbuf) \ 525#define __sanitizer_syscall_post_stat64(res, filename, statbuf) \
526 __sanitizer_syscall_post_impl_stat64(res, (long)(filename), (long)(statbuf)) 526 __sanitizer_syscall_post_impl_stat64(res, (long)(filename), (long)(statbuf))
527#define __sanitizer_syscall_pre_fstat64(fd, statbuf) \ 527#define __sanitizer_syscall_pre_fstat64(fd, statbuf) \
528 __sanitizer_syscall_pre_impl_fstat64((long)(fd), (long)(statbuf)) 528 __sanitizer_syscall_pre_impl_fstat64((long)(fd), (long)(statbuf))
529#define __sanitizer_syscall_post_fstat64(res, fd, statbuf) \ 529#define __sanitizer_syscall_post_fstat64(res, fd, statbuf) \
530 __sanitizer_syscall_post_impl_fstat64(res, (long)(fd), (long)(statbuf)) 530 __sanitizer_syscall_post_impl_fstat64(res, (long)(fd), (long)(statbuf))
531#define __sanitizer_syscall_pre_lstat64(filename, statbuf) \ 531#define __sanitizer_syscall_pre_lstat64(filename, statbuf) \
532 __sanitizer_syscall_pre_impl_lstat64((long)(filename), (long)(statbuf)) 532 __sanitizer_syscall_pre_impl_lstat64((long)(filename), (long)(statbuf))
533#define __sanitizer_syscall_post_lstat64(res, filename, statbuf) \ 533#define __sanitizer_syscall_post_lstat64(res, filename, statbuf) \
534 __sanitizer_syscall_post_impl_lstat64(res, (long)(filename), (long)(statbuf)) 534 __sanitizer_syscall_post_impl_lstat64(res, (long)(filename), (long)(statbuf))
535#define __sanitizer_syscall_pre_setxattr(path, name, value, size, flags) \ 535#define __sanitizer_syscall_pre_setxattr(path, name, value, size, flags) \
536 __sanitizer_syscall_pre_impl_setxattr( \ 536 __sanitizer_syscall_pre_impl_setxattr( \
537 (long)(path), (long)(name), (long)(value), (long)(size), (long)(flags)) 537 (long)(path), (long)(name), (long)(value), (long)(size), (long)(flags))
538#define __sanitizer_syscall_post_setxattr(res, path, name, value, size, flags) \ 538#define __sanitizer_syscall_post_setxattr(res, path, name, value, size, flags) \
539 __sanitizer_syscall_post_impl_setxattr(res, (long)(path), (long)(name), \ 539 __sanitizer_syscall_post_impl_setxattr(res, (long)(path), (long)(name), \
540 (long)(value), (long)(size), \ 540 (long)(value), (long)(size), \
541 (long)(flags)) 541 (long)(flags))
542#define __sanitizer_syscall_pre_lsetxattr(path, name, value, size, flags) \ 542#define __sanitizer_syscall_pre_lsetxattr(path, name, value, size, flags) \
543 __sanitizer_syscall_pre_impl_lsetxattr( \ 543 __sanitizer_syscall_pre_impl_lsetxattr( \
544 (long)(path), (long)(name), (long)(value), (long)(size), (long)(flags)) 544 (long)(path), (long)(name), (long)(value), (long)(size), (long)(flags))
545#define __sanitizer_syscall_post_lsetxattr(res, path, name, value, size, \ 545#define __sanitizer_syscall_post_lsetxattr(res, path, name, value, size, \
546 flags) \ 546 flags) \
547 __sanitizer_syscall_post_impl_lsetxattr(res, (long)(path), (long)(name), \ 547 __sanitizer_syscall_post_impl_lsetxattr(res, (long)(path), (long)(name), \
548 (long)(value), (long)(size), \ 548 (long)(value), (long)(size), \
549 (long)(flags)) 549 (long)(flags))
550#define __sanitizer_syscall_pre_fsetxattr(fd, name, value, size, flags) \ 550#define __sanitizer_syscall_pre_fsetxattr(fd, name, value, size, flags) \
551 __sanitizer_syscall_pre_impl_fsetxattr( \ 551 __sanitizer_syscall_pre_impl_fsetxattr( \
552 (long)(fd), (long)(name), (long)(value), (long)(size), (long)(flags)) 552 (long)(fd), (long)(name), (long)(value), (long)(size), (long)(flags))
553#define __sanitizer_syscall_post_fsetxattr(res, fd, name, value, size, flags) \ 553#define __sanitizer_syscall_post_fsetxattr(res, fd, name, value, size, flags) \
554 __sanitizer_syscall_post_impl_fsetxattr(res, (long)(fd), (long)(name), \ 554 __sanitizer_syscall_post_impl_fsetxattr(res, (long)(fd), (long)(name), \
555 (long)(value), (long)(size), \ 555 (long)(value), (long)(size), \
556 (long)(flags)) 556 (long)(flags))
557#define __sanitizer_syscall_pre_getxattr(path, name, value, size) \ 557#define __sanitizer_syscall_pre_getxattr(path, name, value, size) \
558 __sanitizer_syscall_pre_impl_getxattr((long)(path), (long)(name), \ 558 __sanitizer_syscall_pre_impl_getxattr((long)(path), (long)(name), \
559 (long)(value), (long)(size)) 559 (long)(value), (long)(size))
560#define __sanitizer_syscall_post_getxattr(res, path, name, value, size) \ 560#define __sanitizer_syscall_post_getxattr(res, path, name, value, size) \
561 __sanitizer_syscall_post_impl_getxattr(res, (long)(path), (long)(name), \ 561 __sanitizer_syscall_post_impl_getxattr(res, (long)(path), (long)(name), \
562 (long)(value), (long)(size)) 562 (long)(value), (long)(size))
563#define __sanitizer_syscall_pre_lgetxattr(path, name, value, size) \ 563#define __sanitizer_syscall_pre_lgetxattr(path, name, value, size) \
564 __sanitizer_syscall_pre_impl_lgetxattr((long)(path), (long)(name), \ 564 __sanitizer_syscall_pre_impl_lgetxattr((long)(path), (long)(name), \
565 (long)(value), (long)(size)) 565 (long)(value), (long)(size))
566#define __sanitizer_syscall_post_lgetxattr(res, path, name, value, size) \ 566#define __sanitizer_syscall_post_lgetxattr(res, path, name, value, size) \
567 __sanitizer_syscall_post_impl_lgetxattr(res, (long)(path), (long)(name), \ 567 __sanitizer_syscall_post_impl_lgetxattr(res, (long)(path), (long)(name), \
568 (long)(value), (long)(size)) 568 (long)(value), (long)(size))
569#define __sanitizer_syscall_pre_fgetxattr(fd, name, value, size) \ 569#define __sanitizer_syscall_pre_fgetxattr(fd, name, value, size) \
570 __sanitizer_syscall_pre_impl_fgetxattr((long)(fd), (long)(name), \ 570 __sanitizer_syscall_pre_impl_fgetxattr((long)(fd), (long)(name), \
571 (long)(value), (long)(size)) 571 (long)(value), (long)(size))
572#define __sanitizer_syscall_post_fgetxattr(res, fd, name, value, size) \ 572#define __sanitizer_syscall_post_fgetxattr(res, fd, name, value, size) \
573 __sanitizer_syscall_post_impl_fgetxattr(res, (long)(fd), (long)(name), \ 573 __sanitizer_syscall_post_impl_fgetxattr(res, (long)(fd), (long)(name), \
574 (long)(value), (long)(size)) 574 (long)(value), (long)(size))
575#define __sanitizer_syscall_pre_listxattr(path, list, size) \ 575#define __sanitizer_syscall_pre_listxattr(path, list, size) \
576 __sanitizer_syscall_pre_impl_listxattr((long)(path), (long)(list), \ 576 __sanitizer_syscall_pre_impl_listxattr((long)(path), (long)(list), \
577 (long)(size)) 577 (long)(size))
578#define __sanitizer_syscall_post_listxattr(res, path, list, size) \ 578#define __sanitizer_syscall_post_listxattr(res, path, list, size) \
579 __sanitizer_syscall_post_impl_listxattr(res, (long)(path), (long)(list), \ 579 __sanitizer_syscall_post_impl_listxattr(res, (long)(path), (long)(list), \
580 (long)(size)) 580 (long)(size))
581#define __sanitizer_syscall_pre_llistxattr(path, list, size) \ 581#define __sanitizer_syscall_pre_llistxattr(path, list, size) \
582 __sanitizer_syscall_pre_impl_llistxattr((long)(path), (long)(list), \ 582 __sanitizer_syscall_pre_impl_llistxattr((long)(path), (long)(list), \
583 (long)(size)) 583 (long)(size))
584#define __sanitizer_syscall_post_llistxattr(res, path, list, size) \ 584#define __sanitizer_syscall_post_llistxattr(res, path, list, size) \
585 __sanitizer_syscall_post_impl_llistxattr(res, (long)(path), (long)(list), \ 585 __sanitizer_syscall_post_impl_llistxattr(res, (long)(path), (long)(list), \
586 (long)(size)) 586 (long)(size))
587#define __sanitizer_syscall_pre_flistxattr(fd, list, size) \ 587#define __sanitizer_syscall_pre_flistxattr(fd, list, size) \
588 __sanitizer_syscall_pre_impl_flistxattr((long)(fd), (long)(list), \ 588 __sanitizer_syscall_pre_impl_flistxattr((long)(fd), (long)(list), \
589 (long)(size)) 589 (long)(size))
590#define __sanitizer_syscall_post_flistxattr(res, fd, list, size) \ 590#define __sanitizer_syscall_post_flistxattr(res, fd, list, size) \
591 __sanitizer_syscall_post_impl_flistxattr(res, (long)(fd), (long)(list), \ 591 __sanitizer_syscall_post_impl_flistxattr(res, (long)(fd), (long)(list), \
592 (long)(size)) 592 (long)(size))
593#define __sanitizer_syscall_pre_removexattr(path, name) \ 593#define __sanitizer_syscall_pre_removexattr(path, name) \
594 __sanitizer_syscall_pre_impl_removexattr((long)(path), (long)(name)) 594 __sanitizer_syscall_pre_impl_removexattr((long)(path), (long)(name))
595#define __sanitizer_syscall_post_removexattr(res, path, name) \ 595#define __sanitizer_syscall_post_removexattr(res, path, name) \
596 __sanitizer_syscall_post_impl_removexattr(res, (long)(path), (long)(name)) 596 __sanitizer_syscall_post_impl_removexattr(res, (long)(path), (long)(name))
597#define __sanitizer_syscall_pre_lremovexattr(path, name) \ 597#define __sanitizer_syscall_pre_lremovexattr(path, name) \
598 __sanitizer_syscall_pre_impl_lremovexattr((long)(path), (long)(name)) 598 __sanitizer_syscall_pre_impl_lremovexattr((long)(path), (long)(name))
599#define __sanitizer_syscall_post_lremovexattr(res, path, name) \ 599#define __sanitizer_syscall_post_lremovexattr(res, path, name) \
600 __sanitizer_syscall_post_impl_lremovexattr(res, (long)(path), (long)(name)) 600 __sanitizer_syscall_post_impl_lremovexattr(res, (long)(path), (long)(name))
601#define __sanitizer_syscall_pre_fremovexattr(fd, name) \ 601#define __sanitizer_syscall_pre_fremovexattr(fd, name) \
602 __sanitizer_syscall_pre_impl_fremovexattr((long)(fd), (long)(name)) 602 __sanitizer_syscall_pre_impl_fremovexattr((long)(fd), (long)(name))
603#define __sanitizer_syscall_post_fremovexattr(res, fd, name) \ 603#define __sanitizer_syscall_post_fremovexattr(res, fd, name) \
604 __sanitizer_syscall_post_impl_fremovexattr(res, (long)(fd), (long)(name)) 604 __sanitizer_syscall_post_impl_fremovexattr(res, (long)(fd), (long)(name))
605#define __sanitizer_syscall_pre_brk(brk) \ 605#define __sanitizer_syscall_pre_brk(brk) \
606 __sanitizer_syscall_pre_impl_brk((long)(brk)) 606 __sanitizer_syscall_pre_impl_brk((long)(brk))
607#define __sanitizer_syscall_post_brk(res, brk) \ 607#define __sanitizer_syscall_post_brk(res, brk) \
608 __sanitizer_syscall_post_impl_brk(res, (long)(brk)) 608 __sanitizer_syscall_post_impl_brk(res, (long)(brk))
609#define __sanitizer_syscall_pre_mprotect(start, len, prot) \ 609#define __sanitizer_syscall_pre_mprotect(start, len, prot) \
610 __sanitizer_syscall_pre_impl_mprotect((long)(start), (long)(len), \ 610 __sanitizer_syscall_pre_impl_mprotect((long)(start), (long)(len), \
611 (long)(prot)) 611 (long)(prot))
612#define __sanitizer_syscall_post_mprotect(res, start, len, prot) \ 612#define __sanitizer_syscall_post_mprotect(res, start, len, prot) \
613 __sanitizer_syscall_post_impl_mprotect(res, (long)(start), (long)(len), \ 613 __sanitizer_syscall_post_impl_mprotect(res, (long)(start), (long)(len), \
614 (long)(prot)) 614 (long)(prot))
615#define __sanitizer_syscall_pre_mremap(addr, old_len, new_len, flags, \ 615#define __sanitizer_syscall_pre_mremap(addr, old_len, new_len, flags, \
616 new_addr) \ 616 new_addr) \
617 __sanitizer_syscall_pre_impl_mremap((long)(addr), (long)(old_len), \ 617 __sanitizer_syscall_pre_impl_mremap((long)(addr), (long)(old_len), \
618 (long)(new_len), (long)(flags), \ 618 (long)(new_len), (long)(flags), \
619 (long)(new_addr)) 619 (long)(new_addr))
620#define __sanitizer_syscall_post_mremap(res, addr, old_len, new_len, flags, \ 620#define __sanitizer_syscall_post_mremap(res, addr, old_len, new_len, flags, \
621 new_addr) \ 621 new_addr) \
622 __sanitizer_syscall_post_impl_mremap(res, (long)(addr), (long)(old_len), \ 622 __sanitizer_syscall_post_impl_mremap(res, (long)(addr), (long)(old_len), \
623 (long)(new_len), (long)(flags), \ 623 (long)(new_len), (long)(flags), \
624 (long)(new_addr)) 624 (long)(new_addr))
625#define __sanitizer_syscall_pre_remap_file_pages(start, size, prot, pgoff, \ 625#define __sanitizer_syscall_pre_remap_file_pages(start, size, prot, pgoff, \
626 flags) \ 626 flags) \
627 __sanitizer_syscall_pre_impl_remap_file_pages( \ 627 __sanitizer_syscall_pre_impl_remap_file_pages( \
628 (long)(start), (long)(size), (long)(prot), (long)(pgoff), (long)(flags)) 628 (long)(start), (long)(size), (long)(prot), (long)(pgoff), (long)(flags))
629#define __sanitizer_syscall_post_remap_file_pages(res, start, size, prot, \ 629#define __sanitizer_syscall_post_remap_file_pages(res, start, size, prot, \
630 pgoff, flags) \ 630 pgoff, flags) \
631 __sanitizer_syscall_post_impl_remap_file_pages(res, (long)(start), \ 631 __sanitizer_syscall_post_impl_remap_file_pages(res, (long)(start), \
632 (long)(size), (long)(prot), \ 632 (long)(size), (long)(prot), \
633 (long)(pgoff), (long)(flags)) 633 (long)(pgoff), (long)(flags))
634#define __sanitizer_syscall_pre_msync(start, len, flags) \ 634#define __sanitizer_syscall_pre_msync(start, len, flags) \
635 __sanitizer_syscall_pre_impl_msync((long)(start), (long)(len), (long)(flags)) 635 __sanitizer_syscall_pre_impl_msync((long)(start), (long)(len), (long)(flags))
636#define __sanitizer_syscall_post_msync(res, start, len, flags) \ 636#define __sanitizer_syscall_post_msync(res, start, len, flags) \
637 __sanitizer_syscall_post_impl_msync(res, (long)(start), (long)(len), \ 637 __sanitizer_syscall_post_impl_msync(res, (long)(start), (long)(len), \
638 (long)(flags)) 638 (long)(flags))
639#define __sanitizer_syscall_pre_munmap(addr, len) \ 639#define __sanitizer_syscall_pre_munmap(addr, len) \
640 __sanitizer_syscall_pre_impl_munmap((long)(addr), (long)(len)) 640 __sanitizer_syscall_pre_impl_munmap((long)(addr), (long)(len))
641#define __sanitizer_syscall_post_munmap(res, addr, len) \ 641#define __sanitizer_syscall_post_munmap(res, addr, len) \
642 __sanitizer_syscall_post_impl_munmap(res, (long)(addr), (long)(len)) 642 __sanitizer_syscall_post_impl_munmap(res, (long)(addr), (long)(len))
643#define __sanitizer_syscall_pre_mlock(start, len) \ 643#define __sanitizer_syscall_pre_mlock(start, len) \
644 __sanitizer_syscall_pre_impl_mlock((long)(start), (long)(len)) 644 __sanitizer_syscall_pre_impl_mlock((long)(start), (long)(len))
645#define __sanitizer_syscall_post_mlock(res, start, len) \ 645#define __sanitizer_syscall_post_mlock(res, start, len) \
646 __sanitizer_syscall_post_impl_mlock(res, (long)(start), (long)(len)) 646 __sanitizer_syscall_post_impl_mlock(res, (long)(start), (long)(len))
647#define __sanitizer_syscall_pre_munlock(start, len) \ 647#define __sanitizer_syscall_pre_munlock(start, len) \
648 __sanitizer_syscall_pre_impl_munlock((long)(start), (long)(len)) 648 __sanitizer_syscall_pre_impl_munlock((long)(start), (long)(len))
649#define __sanitizer_syscall_post_munlock(res, start, len) \ 649#define __sanitizer_syscall_post_munlock(res, start, len) \
650 __sanitizer_syscall_post_impl_munlock(res, (long)(start), (long)(len)) 650 __sanitizer_syscall_post_impl_munlock(res, (long)(start), (long)(len))
651#define __sanitizer_syscall_pre_mlockall(flags) \ 651#define __sanitizer_syscall_pre_mlockall(flags) \
652 __sanitizer_syscall_pre_impl_mlockall((long)(flags)) 652 __sanitizer_syscall_pre_impl_mlockall((long)(flags))
653#define __sanitizer_syscall_post_mlockall(res, flags) \ 653#define __sanitizer_syscall_post_mlockall(res, flags) \
654 __sanitizer_syscall_post_impl_mlockall(res, (long)(flags)) 654 __sanitizer_syscall_post_impl_mlockall(res, (long)(flags))
655#define __sanitizer_syscall_pre_munlockall() \ 655#define __sanitizer_syscall_pre_munlockall() \
656 __sanitizer_syscall_pre_impl_munlockall() 656 __sanitizer_syscall_pre_impl_munlockall()
657#define __sanitizer_syscall_post_munlockall(res) \ 657#define __sanitizer_syscall_post_munlockall(res) \
658 __sanitizer_syscall_post_impl_munlockall(res) 658 __sanitizer_syscall_post_impl_munlockall(res)
659#define __sanitizer_syscall_pre_madvise(start, len, behavior) \ 659#define __sanitizer_syscall_pre_madvise(start, len, behavior) \
660 __sanitizer_syscall_pre_impl_madvise((long)(start), (long)(len), \ 660 __sanitizer_syscall_pre_impl_madvise((long)(start), (long)(len), \
661 (long)(behavior)) 661 (long)(behavior))
662#define __sanitizer_syscall_post_madvise(res, start, len, behavior) \ 662#define __sanitizer_syscall_post_madvise(res, start, len, behavior) \
663 __sanitizer_syscall_post_impl_madvise(res, (long)(start), (long)(len), \ 663 __sanitizer_syscall_post_impl_madvise(res, (long)(start), (long)(len), \
664 (long)(behavior)) 664 (long)(behavior))
665#define __sanitizer_syscall_pre_mincore(start, len, vec) \ 665#define __sanitizer_syscall_pre_mincore(start, len, vec) \
666 __sanitizer_syscall_pre_impl_mincore((long)(start), (long)(len), (long)(vec)) 666 __sanitizer_syscall_pre_impl_mincore((long)(start), (long)(len), (long)(vec))
667#define __sanitizer_syscall_post_mincore(res, start, len, vec) \ 667#define __sanitizer_syscall_post_mincore(res, start, len, vec) \
668 __sanitizer_syscall_post_impl_mincore(res, (long)(start), (long)(len), \ 668 __sanitizer_syscall_post_impl_mincore(res, (long)(start), (long)(len), \
669 (long)(vec)) 669 (long)(vec))
670#define __sanitizer_syscall_pre_pivot_root(new_root, put_old) \ 670#define __sanitizer_syscall_pre_pivot_root(new_root, put_old) \
671 __sanitizer_syscall_pre_impl_pivot_root((long)(new_root), (long)(put_old)) 671 __sanitizer_syscall_pre_impl_pivot_root((long)(new_root), (long)(put_old))
672#define __sanitizer_syscall_post_pivot_root(res, new_root, put_old) \ 672#define __sanitizer_syscall_post_pivot_root(res, new_root, put_old) \
673 __sanitizer_syscall_post_impl_pivot_root(res, (long)(new_root), \ 673 __sanitizer_syscall_post_impl_pivot_root(res, (long)(new_root), \
674 (long)(put_old)) 674 (long)(put_old))
675#define __sanitizer_syscall_pre_chroot(filename) \ 675#define __sanitizer_syscall_pre_chroot(filename) \
676 __sanitizer_syscall_pre_impl_chroot((long)(filename)) 676 __sanitizer_syscall_pre_impl_chroot((long)(filename))
677#define __sanitizer_syscall_post_chroot(res, filename) \ 677#define __sanitizer_syscall_post_chroot(res, filename) \
678 __sanitizer_syscall_post_impl_chroot(res, (long)(filename)) 678 __sanitizer_syscall_post_impl_chroot(res, (long)(filename))
679#define __sanitizer_syscall_pre_mknod(filename, mode, dev) \ 679#define __sanitizer_syscall_pre_mknod(filename, mode, dev) \
680 __sanitizer_syscall_pre_impl_mknod((long)(filename), (long)(mode), \ 680 __sanitizer_syscall_pre_impl_mknod((long)(filename), (long)(mode), \
681 (long)(dev)) 681 (long)(dev))
682#define __sanitizer_syscall_post_mknod(res, filename, mode, dev) \ 682#define __sanitizer_syscall_post_mknod(res, filename, mode, dev) \
683 __sanitizer_syscall_post_impl_mknod(res, (long)(filename), (long)(mode), \ 683 __sanitizer_syscall_post_impl_mknod(res, (long)(filename), (long)(mode), \
684 (long)(dev)) 684 (long)(dev))
685#define __sanitizer_syscall_pre_link(oldname, newname) \ 685#define __sanitizer_syscall_pre_link(oldname, newname) \
686 __sanitizer_syscall_pre_impl_link((long)(oldname), (long)(newname)) 686 __sanitizer_syscall_pre_impl_link((long)(oldname), (long)(newname))
687#define __sanitizer_syscall_post_link(res, oldname, newname) \ 687#define __sanitizer_syscall_post_link(res, oldname, newname) \
688 __sanitizer_syscall_post_impl_link(res, (long)(oldname), (long)(newname)) 688 __sanitizer_syscall_post_impl_link(res, (long)(oldname), (long)(newname))
689#define __sanitizer_syscall_pre_symlink(old, new_) \ 689#define __sanitizer_syscall_pre_symlink(old, new_) \
690 __sanitizer_syscall_pre_impl_symlink((long)(old), (long)(new_)) 690 __sanitizer_syscall_pre_impl_symlink((long)(old), (long)(new_))
691#define __sanitizer_syscall_post_symlink(res, old, new_) \ 691#define __sanitizer_syscall_post_symlink(res, old, new_) \
692 __sanitizer_syscall_post_impl_symlink(res, (long)(old), (long)(new_)) 692 __sanitizer_syscall_post_impl_symlink(res, (long)(old), (long)(new_))
693#define __sanitizer_syscall_pre_unlink(pathname) \ 693#define __sanitizer_syscall_pre_unlink(pathname) \
694 __sanitizer_syscall_pre_impl_unlink((long)(pathname)) 694 __sanitizer_syscall_pre_impl_unlink((long)(pathname))
695#define __sanitizer_syscall_post_unlink(res, pathname) \ 695#define __sanitizer_syscall_post_unlink(res, pathname) \
696 __sanitizer_syscall_post_impl_unlink(res, (long)(pathname)) 696 __sanitizer_syscall_post_impl_unlink(res, (long)(pathname))
697#define __sanitizer_syscall_pre_rename(oldname, newname) \ 697#define __sanitizer_syscall_pre_rename(oldname, newname) \
698 __sanitizer_syscall_pre_impl_rename((long)(oldname), (long)(newname)) 698 __sanitizer_syscall_pre_impl_rename((long)(oldname), (long)(newname))
699#define __sanitizer_syscall_post_rename(res, oldname, newname) \ 699#define __sanitizer_syscall_post_rename(res, oldname, newname) \
700 __sanitizer_syscall_post_impl_rename(res, (long)(oldname), (long)(newname)) 700 __sanitizer_syscall_post_impl_rename(res, (long)(oldname), (long)(newname))
701#define __sanitizer_syscall_pre_chmod(filename, mode) \ 701#define __sanitizer_syscall_pre_chmod(filename, mode) \
702 __sanitizer_syscall_pre_impl_chmod((long)(filename), (long)(mode)) 702 __sanitizer_syscall_pre_impl_chmod((long)(filename), (long)(mode))
703#define __sanitizer_syscall_post_chmod(res, filename, mode) \ 703#define __sanitizer_syscall_post_chmod(res, filename, mode) \
704 __sanitizer_syscall_post_impl_chmod(res, (long)(filename), (long)(mode)) 704 __sanitizer_syscall_post_impl_chmod(res, (long)(filename), (long)(mode))
705#define __sanitizer_syscall_pre_fchmod(fd, mode) \ 705#define __sanitizer_syscall_pre_fchmod(fd, mode) \
706 __sanitizer_syscall_pre_impl_fchmod((long)(fd), (long)(mode)) 706 __sanitizer_syscall_pre_impl_fchmod((long)(fd), (long)(mode))
707#define __sanitizer_syscall_post_fchmod(res, fd, mode) \ 707#define __sanitizer_syscall_post_fchmod(res, fd, mode) \
708 __sanitizer_syscall_post_impl_fchmod(res, (long)(fd), (long)(mode)) 708 __sanitizer_syscall_post_impl_fchmod(res, (long)(fd), (long)(mode))
709#define __sanitizer_syscall_pre_fcntl(fd, cmd, arg) \ 709#define __sanitizer_syscall_pre_fcntl(fd, cmd, arg) \
710 __sanitizer_syscall_pre_impl_fcntl((long)(fd), (long)(cmd), (long)(arg)) 710 __sanitizer_syscall_pre_impl_fcntl((long)(fd), (long)(cmd), (long)(arg))
711#define __sanitizer_syscall_post_fcntl(res, fd, cmd, arg) \ 711#define __sanitizer_syscall_post_fcntl(res, fd, cmd, arg) \
712 __sanitizer_syscall_post_impl_fcntl(res, (long)(fd), (long)(cmd), (long)(arg)) 712 __sanitizer_syscall_post_impl_fcntl(res, (long)(fd), (long)(cmd), (long)(arg))
713#define __sanitizer_syscall_pre_fcntl64(fd, cmd, arg) \ 713#define __sanitizer_syscall_pre_fcntl64(fd, cmd, arg) \
714 __sanitizer_syscall_pre_impl_fcntl64((long)(fd), (long)(cmd), (long)(arg)) 714 __sanitizer_syscall_pre_impl_fcntl64((long)(fd), (long)(cmd), (long)(arg))
715#define __sanitizer_syscall_post_fcntl64(res, fd, cmd, arg) \ 715#define __sanitizer_syscall_post_fcntl64(res, fd, cmd, arg) \
716 __sanitizer_syscall_post_impl_fcntl64(res, (long)(fd), (long)(cmd), \ 716 __sanitizer_syscall_post_impl_fcntl64(res, (long)(fd), (long)(cmd), \
717 (long)(arg)) 717 (long)(arg))
718#define __sanitizer_syscall_pre_pipe(fildes) \ 718#define __sanitizer_syscall_pre_pipe(fildes) \
719 __sanitizer_syscall_pre_impl_pipe((long)(fildes)) 719 __sanitizer_syscall_pre_impl_pipe((long)(fildes))
720#define __sanitizer_syscall_post_pipe(res, fildes) \ 720#define __sanitizer_syscall_post_pipe(res, fildes) \
721 __sanitizer_syscall_post_impl_pipe(res, (long)(fildes)) 721 __sanitizer_syscall_post_impl_pipe(res, (long)(fildes))
722#define __sanitizer_syscall_pre_pipe2(fildes, flags) \ 722#define __sanitizer_syscall_pre_pipe2(fildes, flags) \
723 __sanitizer_syscall_pre_impl_pipe2((long)(fildes), (long)(flags)) 723 __sanitizer_syscall_pre_impl_pipe2((long)(fildes), (long)(flags))
724#define __sanitizer_syscall_post_pipe2(res, fildes, flags) \ 724#define __sanitizer_syscall_post_pipe2(res, fildes, flags) \
725 __sanitizer_syscall_post_impl_pipe2(res, (long)(fildes), (long)(flags)) 725 __sanitizer_syscall_post_impl_pipe2(res, (long)(fildes), (long)(flags))
726#define __sanitizer_syscall_pre_dup(fildes) \ 726#define __sanitizer_syscall_pre_dup(fildes) \
727 __sanitizer_syscall_pre_impl_dup((long)(fildes)) 727 __sanitizer_syscall_pre_impl_dup((long)(fildes))
728#define __sanitizer_syscall_post_dup(res, fildes) \ 728#define __sanitizer_syscall_post_dup(res, fildes) \
729 __sanitizer_syscall_post_impl_dup(res, (long)(fildes)) 729 __sanitizer_syscall_post_impl_dup(res, (long)(fildes))
730#define __sanitizer_syscall_pre_dup2(oldfd, newfd) \ 730#define __sanitizer_syscall_pre_dup2(oldfd, newfd) \
731 __sanitizer_syscall_pre_impl_dup2((long)(oldfd), (long)(newfd)) 731 __sanitizer_syscall_pre_impl_dup2((long)(oldfd), (long)(newfd))
732#define __sanitizer_syscall_post_dup2(res, oldfd, newfd) \ 732#define __sanitizer_syscall_post_dup2(res, oldfd, newfd) \
733 __sanitizer_syscall_post_impl_dup2(res, (long)(oldfd), (long)(newfd)) 733 __sanitizer_syscall_post_impl_dup2(res, (long)(oldfd), (long)(newfd))
734#define __sanitizer_syscall_pre_dup3(oldfd, newfd, flags) \ 734#define __sanitizer_syscall_pre_dup3(oldfd, newfd, flags) \
735 __sanitizer_syscall_pre_impl_dup3((long)(oldfd), (long)(newfd), (long)(flags)) 735 __sanitizer_syscall_pre_impl_dup3((long)(oldfd), (long)(newfd), (long)(flags))
736#define __sanitizer_syscall_post_dup3(res, oldfd, newfd, flags) \ 736#define __sanitizer_syscall_post_dup3(res, oldfd, newfd, flags) \
737 __sanitizer_syscall_post_impl_dup3(res, (long)(oldfd), (long)(newfd), \ 737 __sanitizer_syscall_post_impl_dup3(res, (long)(oldfd), (long)(newfd), \
738 (long)(flags)) 738 (long)(flags))
739#define __sanitizer_syscall_pre_ioperm(from, num, on) \ 739#define __sanitizer_syscall_pre_ioperm(from, num, on) \
740 __sanitizer_syscall_pre_impl_ioperm((long)(from), (long)(num), (long)(on)) 740 __sanitizer_syscall_pre_impl_ioperm((long)(from), (long)(num), (long)(on))
741#define __sanitizer_syscall_post_ioperm(res, from, num, on) \ 741#define __sanitizer_syscall_post_ioperm(res, from, num, on) \
742 __sanitizer_syscall_post_impl_ioperm(res, (long)(from), (long)(num), \ 742 __sanitizer_syscall_post_impl_ioperm(res, (long)(from), (long)(num), \
743 (long)(on)) 743 (long)(on))
744#define __sanitizer_syscall_pre_ioctl(fd, cmd, arg) \ 744#define __sanitizer_syscall_pre_ioctl(fd, cmd, arg) \
745 __sanitizer_syscall_pre_impl_ioctl((long)(fd), (long)(cmd), (long)(arg)) 745 __sanitizer_syscall_pre_impl_ioctl((long)(fd), (long)(cmd), (long)(arg))
746#define __sanitizer_syscall_post_ioctl(res, fd, cmd, arg) \ 746#define __sanitizer_syscall_post_ioctl(res, fd, cmd, arg) \
747 __sanitizer_syscall_post_impl_ioctl(res, (long)(fd), (long)(cmd), (long)(arg)) 747 __sanitizer_syscall_post_impl_ioctl(res, (long)(fd), (long)(cmd), (long)(arg))
748#define __sanitizer_syscall_pre_flock(fd, cmd) \ 748#define __sanitizer_syscall_pre_flock(fd, cmd) \
749 __sanitizer_syscall_pre_impl_flock((long)(fd), (long)(cmd)) 749 __sanitizer_syscall_pre_impl_flock((long)(fd), (long)(cmd))
750#define __sanitizer_syscall_post_flock(res, fd, cmd) \ 750#define __sanitizer_syscall_post_flock(res, fd, cmd) \
751 __sanitizer_syscall_post_impl_flock(res, (long)(fd), (long)(cmd)) 751 __sanitizer_syscall_post_impl_flock(res, (long)(fd), (long)(cmd))
752#define __sanitizer_syscall_pre_io_setup(nr_reqs, ctx) \ 752#define __sanitizer_syscall_pre_io_setup(nr_reqs, ctx) \
753 __sanitizer_syscall_pre_impl_io_setup((long)(nr_reqs), (long)(ctx)) 753 __sanitizer_syscall_pre_impl_io_setup((long)(nr_reqs), (long)(ctx))
754#define __sanitizer_syscall_post_io_setup(res, nr_reqs, ctx) \ 754#define __sanitizer_syscall_post_io_setup(res, nr_reqs, ctx) \
755 __sanitizer_syscall_post_impl_io_setup(res, (long)(nr_reqs), (long)(ctx)) 755 __sanitizer_syscall_post_impl_io_setup(res, (long)(nr_reqs), (long)(ctx))
756#define __sanitizer_syscall_pre_io_destroy(ctx) \ 756#define __sanitizer_syscall_pre_io_destroy(ctx) \
757 __sanitizer_syscall_pre_impl_io_destroy((long)(ctx)) 757 __sanitizer_syscall_pre_impl_io_destroy((long)(ctx))
758#define __sanitizer_syscall_post_io_destroy(res, ctx) \ 758#define __sanitizer_syscall_post_io_destroy(res, ctx) \
759 __sanitizer_syscall_post_impl_io_destroy(res, (long)(ctx)) 759 __sanitizer_syscall_post_impl_io_destroy(res, (long)(ctx))
760#define __sanitizer_syscall_pre_io_getevents(ctx_id, min_nr, nr, events, \ 760#define __sanitizer_syscall_pre_io_getevents(ctx_id, min_nr, nr, events, \
761 timeout) \ 761 timeout) \
762 __sanitizer_syscall_pre_impl_io_getevents((long)(ctx_id), (long)(min_nr), \ 762 __sanitizer_syscall_pre_impl_io_getevents((long)(ctx_id), (long)(min_nr), \
763 (long)(nr), (long)(events), \ 763 (long)(nr), (long)(events), \
764 (long)(timeout)) 764 (long)(timeout))
765#define __sanitizer_syscall_post_io_getevents(res, ctx_id, min_nr, nr, events, \ 765#define __sanitizer_syscall_post_io_getevents(res, ctx_id, min_nr, nr, events, \
766 timeout) \ 766 timeout) \
767 __sanitizer_syscall_post_impl_io_getevents(res, (long)(ctx_id), \ 767 __sanitizer_syscall_post_impl_io_getevents(res, (long)(ctx_id), \
768 (long)(min_nr), (long)(nr), \ 768 (long)(min_nr), (long)(nr), \
769 (long)(events), (long)(timeout)) 769 (long)(events), (long)(timeout))
770#define __sanitizer_syscall_pre_io_submit(ctx_id, arg1, arg2) \ 770#define __sanitizer_syscall_pre_io_submit(ctx_id, arg1, arg2) \
771 __sanitizer_syscall_pre_impl_io_submit((long)(ctx_id), (long)(arg1), \ 771 __sanitizer_syscall_pre_impl_io_submit((long)(ctx_id), (long)(arg1), \
772 (long)(arg2)) 772 (long)(arg2))
773#define __sanitizer_syscall_post_io_submit(res, ctx_id, arg1, arg2) \ 773#define __sanitizer_syscall_post_io_submit(res, ctx_id, arg1, arg2) \
774 __sanitizer_syscall_post_impl_io_submit(res, (long)(ctx_id), (long)(arg1), \ 774 __sanitizer_syscall_post_impl_io_submit(res, (long)(ctx_id), (long)(arg1), \
775 (long)(arg2)) 775 (long)(arg2))
776#define __sanitizer_syscall_pre_io_cancel(ctx_id, iocb, result) \ 776#define __sanitizer_syscall_pre_io_cancel(ctx_id, iocb, result) \
777 __sanitizer_syscall_pre_impl_io_cancel((long)(ctx_id), (long)(iocb), \ 777 __sanitizer_syscall_pre_impl_io_cancel((long)(ctx_id), (long)(iocb), \
778 (long)(result)) 778 (long)(result))
779#define __sanitizer_syscall_post_io_cancel(res, ctx_id, iocb, result) \ 779#define __sanitizer_syscall_post_io_cancel(res, ctx_id, iocb, result) \
780 __sanitizer_syscall_post_impl_io_cancel(res, (long)(ctx_id), (long)(iocb), \ 780 __sanitizer_syscall_post_impl_io_cancel(res, (long)(ctx_id), (long)(iocb), \