1 //===-- asan_interceptors.cc ----------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file is a part of AddressSanitizer, an address sanity checker.
11 // Intercept various libc functions.
12 //===----------------------------------------------------------------------===//
14 #include "asan_interceptors.h"
15 #include "asan_allocator.h"
16 #include "asan_internal.h"
17 #include "asan_mapping.h"
18 #include "asan_poisoning.h"
19 #include "asan_report.h"
20 #include "asan_stack.h"
21 #include "asan_stats.h"
22 #include "asan_suppressions.h"
23 #include "lsan/lsan_common.h"
24 #include "sanitizer_common/sanitizer_libc.h"
26 // There is no general interception at all on Fuchsia and RTEMS.
27 // Only the functions in asan_interceptors_memintrinsics.cc are
28 // really defined to replace libc functions.
29 #if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS
32 #include "sanitizer_common/sanitizer_posix.h"
35 #if ASAN_INTERCEPT__UNWIND_RAISEEXCEPTION || \
36 ASAN_INTERCEPT__SJLJ_UNWIND_RAISEEXCEPTION
40 #if defined(__i386) && SANITIZER_LINUX
41 #define ASAN_PTHREAD_CREATE_VERSION "GLIBC_2.1"
42 #elif defined(__mips__) && SANITIZER_LINUX
43 #define ASAN_PTHREAD_CREATE_VERSION "GLIBC_2.2"
48 #define ASAN_READ_STRING_OF_LEN(ctx, s, len, n) \
49 ASAN_READ_RANGE((ctx), (s), \
50 common_flags()->strict_string_checks ? (len) + 1 : (n))
52 #define ASAN_READ_STRING(ctx, s, n) \
53 ASAN_READ_STRING_OF_LEN((ctx), (s), REAL(strlen)(s), (n))
55 static inline uptr MaybeRealStrnlen(const char *s, uptr maxlen) {
56 #if SANITIZER_INTERCEPT_STRNLEN
58 return REAL(strnlen)(s, maxlen);
61 return internal_strnlen(s, maxlen);
64 void SetThreadName(const char *name) {
65 AsanThread *t = GetCurrentThread();
67 asanThreadRegistry().SetThreadName(t->tid(), name);
71 if (CAN_SANITIZE_LEAKS && common_flags()->detect_leaks &&
72 __lsan::HasReportedLeaks()) {
73 return common_flags()->exitcode;
75 // FIXME: ask frontend whether we need to return failure.
81 // ---------------------- Wrappers ---------------- {{{1
82 using namespace __asan; // NOLINT
84 DECLARE_REAL_AND_INTERCEPTOR(void *, malloc, uptr)
85 DECLARE_REAL_AND_INTERCEPTOR(void, free, void *)
87 #define ASAN_INTERCEPTOR_ENTER(ctx, func) \
88 AsanInterceptorContext _ctx = {#func}; \
89 ctx = (void *)&_ctx; \
92 #define COMMON_INTERCEPT_FUNCTION(name) ASAN_INTERCEPT_FUNC(name)
93 #define COMMON_INTERCEPT_FUNCTION_VER(name, ver) \
94 ASAN_INTERCEPT_FUNC_VER(name, ver)
95 #define COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, size) \
96 ASAN_WRITE_RANGE(ctx, ptr, size)
97 #define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) \
98 ASAN_READ_RANGE(ctx, ptr, size)
99 #define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \
100 ASAN_INTERCEPTOR_ENTER(ctx, func); \
102 if (asan_init_is_running) \
103 return REAL(func)(__VA_ARGS__); \
104 if (SANITIZER_MAC && UNLIKELY(!asan_inited)) \
105 return REAL(func)(__VA_ARGS__); \
106 ENSURE_ASAN_INITED(); \
108 #define COMMON_INTERCEPTOR_DIR_ACQUIRE(ctx, path) \
111 #define COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd) \
114 #define COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd) \
117 #define COMMON_INTERCEPTOR_FD_SOCKET_ACCEPT(ctx, fd, newfd) \
120 #define COMMON_INTERCEPTOR_SET_THREAD_NAME(ctx, name) SetThreadName(name)
121 // Should be asanThreadRegistry().SetThreadNameByUserId(thread, name)
122 // But asan does not remember UserId's for threads (pthread_t);
123 // and remembers all ever existed threads, so the linear search by UserId
125 #define COMMON_INTERCEPTOR_SET_PTHREAD_NAME(ctx, thread, name) \
128 #define COMMON_INTERCEPTOR_BLOCK_REAL(name) REAL(name)
129 // Strict init-order checking is dlopen-hostile:
130 // https://github.com/google/sanitizers/issues/178
131 #define COMMON_INTERCEPTOR_ON_DLOPEN(filename, flag) \
133 if (flags()->strict_init_order) \
134 StopInitOrderChecking(); \
135 CheckNoDeepBind(filename, flag); \
137 #define COMMON_INTERCEPTOR_ON_EXIT(ctx) OnExit()
138 #define COMMON_INTERCEPTOR_LIBRARY_LOADED(filename, handle)
139 #define COMMON_INTERCEPTOR_LIBRARY_UNLOADED()
140 #define COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED (!asan_inited)
141 #define COMMON_INTERCEPTOR_GET_TLS_RANGE(begin, end) \
142 if (AsanThread *t = GetCurrentThread()) { \
143 *begin = t->tls_begin(); \
144 *end = t->tls_end(); \
149 #define COMMON_INTERCEPTOR_MEMMOVE_IMPL(ctx, to, from, size) \
151 ASAN_INTERCEPTOR_ENTER(ctx, memmove); \
152 ASAN_MEMMOVE_IMPL(ctx, to, from, size); \
155 #define COMMON_INTERCEPTOR_MEMCPY_IMPL(ctx, to, from, size) \
157 ASAN_INTERCEPTOR_ENTER(ctx, memcpy); \
158 ASAN_MEMCPY_IMPL(ctx, to, from, size); \
161 #define COMMON_INTERCEPTOR_MEMSET_IMPL(ctx, block, c, size) \
163 ASAN_INTERCEPTOR_ENTER(ctx, memset); \
164 ASAN_MEMSET_IMPL(ctx, block, c, size); \
167 #include "sanitizer_common/sanitizer_common_interceptors.inc"
168 #include "sanitizer_common/sanitizer_signal_interceptors.inc"
170 // Syscall interceptors don't have contexts, we don't support suppressions
172 #define COMMON_SYSCALL_PRE_READ_RANGE(p, s) ASAN_READ_RANGE(nullptr, p, s)
173 #define COMMON_SYSCALL_PRE_WRITE_RANGE(p, s) ASAN_WRITE_RANGE(nullptr, p, s)
174 #define COMMON_SYSCALL_POST_READ_RANGE(p, s) \
179 #define COMMON_SYSCALL_POST_WRITE_RANGE(p, s) \
184 #include "sanitizer_common/sanitizer_common_syscalls.inc"
185 #include "sanitizer_common/sanitizer_syscalls_netbsd.inc"
187 struct ThreadStartParam {
189 atomic_uintptr_t is_registered;
192 #if ASAN_INTERCEPT_PTHREAD_CREATE
193 static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
194 ThreadStartParam *param = reinterpret_cast<ThreadStartParam *>(arg);
195 AsanThread *t = nullptr;
196 while ((t = reinterpret_cast<AsanThread *>(
197 atomic_load(¶m->t, memory_order_acquire))) == nullptr)
198 internal_sched_yield();
200 return t->ThreadStart(GetTid(), ¶m->is_registered);
203 INTERCEPTOR(int, pthread_create, void *thread,
204 void *attr, void *(*start_routine)(void*), void *arg) {
205 EnsureMainThreadIDIsCorrect();
206 // Strict init-order checking is thread-hostile.
207 if (flags()->strict_init_order)
208 StopInitOrderChecking();
209 GET_STACK_TRACE_THREAD;
212 REAL(pthread_attr_getdetachstate)(attr, &detached);
213 ThreadStartParam param;
214 atomic_store(¶m.t, 0, memory_order_relaxed);
215 atomic_store(¶m.is_registered, 0, memory_order_relaxed);
218 // Ignore all allocations made by pthread_create: thread stack/TLS may be
219 // stored by pthread for future reuse even after thread destruction, and
220 // the linked list it's stored in doesn't even hold valid pointers to the
221 // objects, the latter are calculated by obscure pointer arithmetic.
222 #if CAN_SANITIZE_LEAKS
223 __lsan::ScopedInterceptorDisabler disabler;
225 result = REAL(pthread_create)(thread, attr, asan_thread_start, ¶m);
228 u32 current_tid = GetCurrentTidOrInvalid();
230 AsanThread::Create(start_routine, arg, current_tid, &stack, detached);
231 atomic_store(¶m.t, reinterpret_cast<uptr>(t), memory_order_release);
232 // Wait until the AsanThread object is initialized and the ThreadRegistry
233 // entry is in "started" state. One reason for this is that after this
234 // interceptor exits, the child thread's stack may be the only thing holding
235 // the |arg| pointer. This may cause LSan to report a leak if leak checking
236 // happens at a point when the interceptor has already exited, but the stack
237 // range for the child thread is not yet known.
238 while (atomic_load(¶m.is_registered, memory_order_acquire) == 0)
239 internal_sched_yield();
244 INTERCEPTOR(int, pthread_join, void *t, void **arg) {
245 return real_pthread_join(t, arg);
248 DEFINE_REAL_PTHREAD_FUNCTIONS
249 #endif // ASAN_INTERCEPT_PTHREAD_CREATE
251 #if ASAN_INTERCEPT_SWAPCONTEXT
252 static void ClearShadowMemoryForContextStack(uptr stack, uptr ssize) {
253 // Align to page size.
254 uptr PageSize = GetPageSizeCached();
255 uptr bottom = stack & ~(PageSize - 1);
256 ssize += stack - bottom;
257 ssize = RoundUpTo(ssize, PageSize);
258 static const uptr kMaxSaneContextStackSize = 1 << 22; // 4 Mb
259 if (AddrIsInMem(bottom) && ssize && ssize <= kMaxSaneContextStackSize) {
260 PoisonShadow(bottom, ssize, 0);
264 INTERCEPTOR(int, swapcontext, struct ucontext_t *oucp,
265 struct ucontext_t *ucp) {
266 static bool reported_warning = false;
267 if (!reported_warning) {
268 Report("WARNING: ASan doesn't fully support makecontext/swapcontext "
269 "functions and may produce false positives in some cases!\n");
270 reported_warning = true;
272 // Clear shadow memory for new context (it may share stack
273 // with current context).
275 ReadContextStack(ucp, &stack, &ssize);
276 ClearShadowMemoryForContextStack(stack, ssize);
277 #if __has_attribute(__indirect_return__) && \
278 (defined(__x86_64__) || defined(__i386__))
279 int (*real_swapcontext)(struct ucontext_t *, struct ucontext_t *)
280 __attribute__((__indirect_return__))
282 int res = real_swapcontext(oucp, ucp);
284 int res = REAL(swapcontext)(oucp, ucp);
286 // swapcontext technically does not return, but program may swap context to
287 // "oucp" later, that would look as if swapcontext() returned 0.
288 // We need to clear shadow for ucp once again, as it may be in arbitrary
290 ClearShadowMemoryForContextStack(stack, ssize);
293 #endif // ASAN_INTERCEPT_SWAPCONTEXT
296 #define longjmp __longjmp14
297 #define siglongjmp __siglongjmp14
300 INTERCEPTOR(void, longjmp, void *env, int val) {
301 __asan_handle_no_return();
302 REAL(longjmp)(env, val);
305 #if ASAN_INTERCEPT__LONGJMP
306 INTERCEPTOR(void, _longjmp, void *env, int val) {
307 __asan_handle_no_return();
308 REAL(_longjmp)(env, val);
312 #if ASAN_INTERCEPT___LONGJMP_CHK
313 INTERCEPTOR(void, __longjmp_chk, void *env, int val) {
314 __asan_handle_no_return();
315 REAL(__longjmp_chk)(env, val);
319 #if ASAN_INTERCEPT_SIGLONGJMP
320 INTERCEPTOR(void, siglongjmp, void *env, int val) {
321 __asan_handle_no_return();
322 REAL(siglongjmp)(env, val);
326 #if ASAN_INTERCEPT___CXA_THROW
327 INTERCEPTOR(void, __cxa_throw, void *a, void *b, void *c) {
328 CHECK(REAL(__cxa_throw));
329 __asan_handle_no_return();
330 REAL(__cxa_throw)(a, b, c);
334 #if ASAN_INTERCEPT___CXA_RETHROW_PRIMARY_EXCEPTION
335 INTERCEPTOR(void, __cxa_rethrow_primary_exception, void *a) {
336 CHECK(REAL(__cxa_rethrow_primary_exception));
337 __asan_handle_no_return();
338 REAL(__cxa_rethrow_primary_exception)(a);
342 #if ASAN_INTERCEPT__UNWIND_RAISEEXCEPTION
343 INTERCEPTOR(_Unwind_Reason_Code, _Unwind_RaiseException,
344 _Unwind_Exception *object) {
345 CHECK(REAL(_Unwind_RaiseException));
346 __asan_handle_no_return();
347 return REAL(_Unwind_RaiseException)(object);
351 #if ASAN_INTERCEPT__SJLJ_UNWIND_RAISEEXCEPTION
352 INTERCEPTOR(_Unwind_Reason_Code, _Unwind_SjLj_RaiseException,
353 _Unwind_Exception *object) {
354 CHECK(REAL(_Unwind_SjLj_RaiseException));
355 __asan_handle_no_return();
356 return REAL(_Unwind_SjLj_RaiseException)(object);
360 #if ASAN_INTERCEPT_INDEX
361 # if ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX
362 INTERCEPTOR(char*, index, const char *string, int c)
363 ALIAS(WRAPPER_NAME(strchr));
366 DECLARE_REAL(char*, index, const char *string, int c)
367 OVERRIDE_FUNCTION(index, strchr);
369 DEFINE_REAL(char*, index, const char *string, int c)
372 #endif // ASAN_INTERCEPT_INDEX
374 // For both strcat() and strncat() we need to check the validity of |to|
375 // argument irrespective of the |from| length.
376 INTERCEPTOR(char*, strcat, char *to, const char *from) { // NOLINT
378 ASAN_INTERCEPTOR_ENTER(ctx, strcat); // NOLINT
379 ENSURE_ASAN_INITED();
380 if (flags()->replace_str) {
381 uptr from_length = REAL(strlen)(from);
382 ASAN_READ_RANGE(ctx, from, from_length + 1);
383 uptr to_length = REAL(strlen)(to);
384 ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length);
385 ASAN_WRITE_RANGE(ctx, to + to_length, from_length + 1);
386 // If the copying actually happens, the |from| string should not overlap
387 // with the resulting string starting at |to|, which has a length of
388 // to_length + from_length + 1.
389 if (from_length > 0) {
390 CHECK_RANGES_OVERLAP("strcat", to, from_length + to_length + 1,
391 from, from_length + 1);
394 return REAL(strcat)(to, from); // NOLINT
397 INTERCEPTOR(char*, strncat, char *to, const char *from, uptr size) {
399 ASAN_INTERCEPTOR_ENTER(ctx, strncat);
400 ENSURE_ASAN_INITED();
401 if (flags()->replace_str) {
402 uptr from_length = MaybeRealStrnlen(from, size);
403 uptr copy_length = Min(size, from_length + 1);
404 ASAN_READ_RANGE(ctx, from, copy_length);
405 uptr to_length = REAL(strlen)(to);
406 ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length);
407 ASAN_WRITE_RANGE(ctx, to + to_length, from_length + 1);
408 if (from_length > 0) {
409 CHECK_RANGES_OVERLAP("strncat", to, to_length + copy_length + 1,
413 return REAL(strncat)(to, from, size);
416 INTERCEPTOR(char*, strcpy, char *to, const char *from) { // NOLINT
418 ASAN_INTERCEPTOR_ENTER(ctx, strcpy); // NOLINT
420 if (UNLIKELY(!asan_inited)) return REAL(strcpy)(to, from); // NOLINT
422 // strcpy is called from malloc_default_purgeable_zone()
423 // in __asan::ReplaceSystemAlloc() on Mac.
424 if (asan_init_is_running) {
425 return REAL(strcpy)(to, from); // NOLINT
427 ENSURE_ASAN_INITED();
428 if (flags()->replace_str) {
429 uptr from_size = REAL(strlen)(from) + 1;
430 CHECK_RANGES_OVERLAP("strcpy", to, from_size, from, from_size);
431 ASAN_READ_RANGE(ctx, from, from_size);
432 ASAN_WRITE_RANGE(ctx, to, from_size);
434 return REAL(strcpy)(to, from); // NOLINT
437 INTERCEPTOR(char*, strdup, const char *s) {
439 ASAN_INTERCEPTOR_ENTER(ctx, strdup);
440 if (UNLIKELY(!asan_inited)) return internal_strdup(s);
441 ENSURE_ASAN_INITED();
442 uptr length = REAL(strlen)(s);
443 if (flags()->replace_str) {
444 ASAN_READ_RANGE(ctx, s, length + 1);
446 GET_STACK_TRACE_MALLOC;
447 void *new_mem = asan_malloc(length + 1, &stack);
448 REAL(memcpy)(new_mem, s, length + 1);
449 return reinterpret_cast<char*>(new_mem);
452 #if ASAN_INTERCEPT___STRDUP
453 INTERCEPTOR(char*, __strdup, const char *s) {
455 ASAN_INTERCEPTOR_ENTER(ctx, strdup);
456 if (UNLIKELY(!asan_inited)) return internal_strdup(s);
457 ENSURE_ASAN_INITED();
458 uptr length = REAL(strlen)(s);
459 if (flags()->replace_str) {
460 ASAN_READ_RANGE(ctx, s, length + 1);
462 GET_STACK_TRACE_MALLOC;
463 void *new_mem = asan_malloc(length + 1, &stack);
464 REAL(memcpy)(new_mem, s, length + 1);
465 return reinterpret_cast<char*>(new_mem);
467 #endif // ASAN_INTERCEPT___STRDUP
469 INTERCEPTOR(char*, strncpy, char *to, const char *from, uptr size) {
471 ASAN_INTERCEPTOR_ENTER(ctx, strncpy);
472 ENSURE_ASAN_INITED();
473 if (flags()->replace_str) {
474 uptr from_size = Min(size, MaybeRealStrnlen(from, size) + 1);
475 CHECK_RANGES_OVERLAP("strncpy", to, from_size, from, from_size);
476 ASAN_READ_RANGE(ctx, from, from_size);
477 ASAN_WRITE_RANGE(ctx, to, size);
479 return REAL(strncpy)(to, from, size);
482 INTERCEPTOR(long, strtol, const char *nptr, // NOLINT
483 char **endptr, int base) {
485 ASAN_INTERCEPTOR_ENTER(ctx, strtol);
486 ENSURE_ASAN_INITED();
487 if (!flags()->replace_str) {
488 return REAL(strtol)(nptr, endptr, base);
491 long result = REAL(strtol)(nptr, &real_endptr, base); // NOLINT
492 StrtolFixAndCheck(ctx, nptr, endptr, real_endptr, base);
496 INTERCEPTOR(int, atoi, const char *nptr) {
498 ASAN_INTERCEPTOR_ENTER(ctx, atoi);
500 if (UNLIKELY(!asan_inited)) return REAL(atoi)(nptr);
502 ENSURE_ASAN_INITED();
503 if (!flags()->replace_str) {
504 return REAL(atoi)(nptr);
507 // "man atoi" tells that behavior of atoi(nptr) is the same as
508 // strtol(nptr, 0, 10), i.e. it sets errno to ERANGE if the
509 // parsed integer can't be stored in *long* type (even if it's
510 // different from int). So, we just imitate this behavior.
511 int result = REAL(strtol)(nptr, &real_endptr, 10);
512 FixRealStrtolEndptr(nptr, &real_endptr);
513 ASAN_READ_STRING(ctx, nptr, (real_endptr - nptr) + 1);
517 INTERCEPTOR(long, atol, const char *nptr) { // NOLINT
519 ASAN_INTERCEPTOR_ENTER(ctx, atol);
521 if (UNLIKELY(!asan_inited)) return REAL(atol)(nptr);
523 ENSURE_ASAN_INITED();
524 if (!flags()->replace_str) {
525 return REAL(atol)(nptr);
528 long result = REAL(strtol)(nptr, &real_endptr, 10); // NOLINT
529 FixRealStrtolEndptr(nptr, &real_endptr);
530 ASAN_READ_STRING(ctx, nptr, (real_endptr - nptr) + 1);
534 #if ASAN_INTERCEPT_ATOLL_AND_STRTOLL
535 INTERCEPTOR(long long, strtoll, const char *nptr, // NOLINT
536 char **endptr, int base) {
538 ASAN_INTERCEPTOR_ENTER(ctx, strtoll);
539 ENSURE_ASAN_INITED();
540 if (!flags()->replace_str) {
541 return REAL(strtoll)(nptr, endptr, base);
544 long long result = REAL(strtoll)(nptr, &real_endptr, base); // NOLINT
545 StrtolFixAndCheck(ctx, nptr, endptr, real_endptr, base);
549 INTERCEPTOR(long long, atoll, const char *nptr) { // NOLINT
551 ASAN_INTERCEPTOR_ENTER(ctx, atoll);
552 ENSURE_ASAN_INITED();
553 if (!flags()->replace_str) {
554 return REAL(atoll)(nptr);
557 long long result = REAL(strtoll)(nptr, &real_endptr, 10); // NOLINT
558 FixRealStrtolEndptr(nptr, &real_endptr);
559 ASAN_READ_STRING(ctx, nptr, (real_endptr - nptr) + 1);
562 #endif // ASAN_INTERCEPT_ATOLL_AND_STRTOLL
564 #if ASAN_INTERCEPT___CXA_ATEXIT
565 static void AtCxaAtexit(void *unused) {
567 StopInitOrderChecking();
570 INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
573 if (UNLIKELY(!asan_inited)) return REAL(__cxa_atexit)(func, arg, dso_handle);
575 ENSURE_ASAN_INITED();
576 int res = REAL(__cxa_atexit)(func, arg, dso_handle);
577 REAL(__cxa_atexit)(AtCxaAtexit, nullptr, nullptr);
580 #endif // ASAN_INTERCEPT___CXA_ATEXIT
582 #if ASAN_INTERCEPT_VFORK
583 DEFINE_REAL(int, vfork)
584 DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(int, vfork)
587 // ---------------------- InitializeAsanInterceptors ---------------- {{{1
589 void InitializeAsanInterceptors() {
590 static bool was_called_once;
591 CHECK(!was_called_once);
592 was_called_once = true;
593 InitializeCommonInterceptors();
594 InitializeSignalInterceptors();
596 // Intercept str* functions.
597 ASAN_INTERCEPT_FUNC(strcat); // NOLINT
598 ASAN_INTERCEPT_FUNC(strcpy); // NOLINT
599 ASAN_INTERCEPT_FUNC(strncat);
600 ASAN_INTERCEPT_FUNC(strncpy);
601 ASAN_INTERCEPT_FUNC(strdup);
602 #if ASAN_INTERCEPT___STRDUP
603 ASAN_INTERCEPT_FUNC(__strdup);
605 #if ASAN_INTERCEPT_INDEX && ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX
606 ASAN_INTERCEPT_FUNC(index);
609 ASAN_INTERCEPT_FUNC(atoi);
610 ASAN_INTERCEPT_FUNC(atol);
611 ASAN_INTERCEPT_FUNC(strtol);
612 #if ASAN_INTERCEPT_ATOLL_AND_STRTOLL
613 ASAN_INTERCEPT_FUNC(atoll);
614 ASAN_INTERCEPT_FUNC(strtoll);
617 // Intecept jump-related functions.
618 ASAN_INTERCEPT_FUNC(longjmp);
620 #if ASAN_INTERCEPT_SWAPCONTEXT
621 ASAN_INTERCEPT_FUNC(swapcontext);
623 #if ASAN_INTERCEPT__LONGJMP
624 ASAN_INTERCEPT_FUNC(_longjmp);
626 #if ASAN_INTERCEPT___LONGJMP_CHK
627 ASAN_INTERCEPT_FUNC(__longjmp_chk);
629 #if ASAN_INTERCEPT_SIGLONGJMP
630 ASAN_INTERCEPT_FUNC(siglongjmp);
633 // Intercept exception handling functions.
634 #if ASAN_INTERCEPT___CXA_THROW
635 ASAN_INTERCEPT_FUNC(__cxa_throw);
637 #if ASAN_INTERCEPT___CXA_RETHROW_PRIMARY_EXCEPTION
638 ASAN_INTERCEPT_FUNC(__cxa_rethrow_primary_exception);
640 // Indirectly intercept std::rethrow_exception.
641 #if ASAN_INTERCEPT__UNWIND_RAISEEXCEPTION
642 INTERCEPT_FUNCTION(_Unwind_RaiseException);
644 // Indirectly intercept std::rethrow_exception.
645 #if ASAN_INTERCEPT__UNWIND_SJLJ_RAISEEXCEPTION
646 INTERCEPT_FUNCTION(_Unwind_SjLj_RaiseException);
649 // Intercept threading-related functions
650 #if ASAN_INTERCEPT_PTHREAD_CREATE
651 #if defined(ASAN_PTHREAD_CREATE_VERSION)
652 ASAN_INTERCEPT_FUNC_VER(pthread_create, ASAN_PTHREAD_CREATE_VERSION);
654 ASAN_INTERCEPT_FUNC(pthread_create);
656 ASAN_INTERCEPT_FUNC(pthread_join);
659 // Intercept atexit function.
660 #if ASAN_INTERCEPT___CXA_ATEXIT
661 ASAN_INTERCEPT_FUNC(__cxa_atexit);
664 #if ASAN_INTERCEPT_VFORK
665 ASAN_INTERCEPT_FUNC(vfork);
668 InitializePlatformInterceptors();
670 VReport(1, "AddressSanitizer: libc interceptors initialized\n");
673 } // namespace __asan
675 #endif // !SANITIZER_FUCHSIA