2012-06-04 21:50:10 +08:00
|
|
|
//===-- asan_interceptors.cc ----------------------------------------------===//
|
2011-11-30 09:07:02 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of AddressSanitizer, an address sanity checker.
|
|
|
|
//
|
2012-01-11 10:32:40 +08:00
|
|
|
// Intercept various libc functions.
|
2011-11-30 09:07:02 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-10-01 08:22:21 +08:00
|
|
|
#include "asan_interceptors.h"
|
2011-11-30 09:07:02 +08:00
|
|
|
#include "asan_allocator.h"
|
|
|
|
#include "asan_internal.h"
|
|
|
|
#include "asan_mapping.h"
|
2013-03-28 23:42:43 +08:00
|
|
|
#include "asan_poisoning.h"
|
2012-08-09 16:32:33 +08:00
|
|
|
#include "asan_report.h"
|
2011-11-30 09:07:02 +08:00
|
|
|
#include "asan_stack.h"
|
|
|
|
#include "asan_stats.h"
|
2014-12-06 04:26:09 +08:00
|
|
|
#include "asan_suppressions.h"
|
2016-01-16 08:57:25 +08:00
|
|
|
#include "lsan/lsan_common.h"
|
2012-06-04 21:27:49 +08:00
|
|
|
#include "sanitizer_common/sanitizer_libc.h"
|
|
|
|
|
2017-08-02 15:59:30 +08:00
|
|
|
// There is no general interception at all on Fuchsia.
|
|
|
|
// Only the functions in asan_interceptors_memintrinsics.cc are
|
|
|
|
// really defined to replace libc functions.
|
|
|
|
#if !SANITIZER_FUCHSIA
|
|
|
|
|
2015-04-09 01:08:24 +08:00
|
|
|
#if SANITIZER_POSIX
|
|
|
|
#include "sanitizer_common/sanitizer_posix.h"
|
|
|
|
#endif
|
|
|
|
|
2015-09-23 05:34:44 +08:00
|
|
|
#if defined(__i386) && SANITIZER_LINUX
|
|
|
|
#define ASAN_PTHREAD_CREATE_VERSION "GLIBC_2.1"
|
2015-10-05 20:43:47 +08:00
|
|
|
#elif defined(__mips__) && SANITIZER_LINUX
|
|
|
|
#define ASAN_PTHREAD_CREATE_VERSION "GLIBC_2.2"
|
2015-09-23 05:34:44 +08:00
|
|
|
#endif
|
|
|
|
|
2011-11-30 09:07:02 +08:00
|
|
|
namespace __asan {
|
|
|
|
|
2015-04-07 02:00:26 +08:00
|
|
|
#define ASAN_READ_STRING_OF_LEN(ctx, s, len, n) \
|
|
|
|
ASAN_READ_RANGE((ctx), (s), \
|
|
|
|
common_flags()->strict_string_checks ? (len) + 1 : (n))
|
|
|
|
|
|
|
|
#define ASAN_READ_STRING(ctx, s, n) \
|
|
|
|
ASAN_READ_STRING_OF_LEN((ctx), (s), REAL(strlen)(s), (n))
|
|
|
|
|
2012-06-15 21:09:52 +08:00
|
|
|
static inline uptr MaybeRealStrnlen(const char *s, uptr maxlen) {
|
2016-03-24 05:24:28 +08:00
|
|
|
#if SANITIZER_INTERCEPT_STRNLEN
|
2015-10-01 08:22:21 +08:00
|
|
|
if (REAL(strnlen)) {
|
2012-02-08 21:45:31 +08:00
|
|
|
return REAL(strnlen)(s, maxlen);
|
2011-11-30 09:07:02 +08:00
|
|
|
}
|
2012-02-02 18:39:40 +08:00
|
|
|
#endif
|
2012-06-15 21:09:52 +08:00
|
|
|
return internal_strnlen(s, maxlen);
|
2012-01-10 06:20:49 +08:00
|
|
|
}
|
2011-11-30 09:07:02 +08:00
|
|
|
|
2013-01-18 14:43:13 +08:00
|
|
|
void SetThreadName(const char *name) {
|
2013-03-20 17:23:28 +08:00
|
|
|
AsanThread *t = GetCurrentThread();
|
2013-01-18 14:43:13 +08:00
|
|
|
if (t)
|
2013-03-21 19:23:41 +08:00
|
|
|
asanThreadRegistry().SetThreadName(t->tid(), name);
|
2013-01-18 14:43:13 +08:00
|
|
|
}
|
|
|
|
|
2013-10-03 23:43:59 +08:00
|
|
|
int OnExit() {
|
Don't call exit() from atexit handlers on Darwin
Summary:
Calling exit() from an atexit handler is undefined behavior.
On Linux, it's unavoidable, since we cannot intercept exit (_exit isn't called
if a user program uses return instead of exit()), and I haven't
seen it cause issues regardless.
However, on Darwin, I have a fairly complex internal test that hangs roughly
once in every 300 runs after leak reporting finishes, which is resolved with
this patch, and is presumably due to the undefined behavior (since the Die() is
the only thing that happens after the end of leak reporting).
In addition, this is the way TSan works as well, where an atexit handler+Die()
is used on Linux, and an _exit() interceptor is used on Darwin. I'm not sure if it's
intentionally structured that way in TSan, since TSan sets up the atexit handler and the
_exit() interceptor on both platforms, but I have observed that on Darwin, only the
_exit() interceptor is used, and on Linux the atexit handler is used.
There is some additional related discussion here: https://reviews.llvm.org/D35085
Reviewers: alekseyshl, kubamracek
Subscribers: eugenis, vsk, llvm-commits
Differential Revision: https://reviews.llvm.org/D35513
llvm-svn: 308353
2017-07-19 04:18:32 +08:00
|
|
|
if (CAN_SANITIZE_LEAKS && common_flags()->detect_leaks &&
|
|
|
|
__lsan::HasReportedLeaks()) {
|
|
|
|
return common_flags()->exitcode;
|
|
|
|
}
|
2013-10-03 23:22:29 +08:00
|
|
|
// FIXME: ask frontend whether we need to return failure.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-01 08:22:21 +08:00
|
|
|
} // namespace __asan
|
2011-11-30 09:07:02 +08:00
|
|
|
|
|
|
|
// ---------------------- Wrappers ---------------- {{{1
|
|
|
|
using namespace __asan; // NOLINT
|
|
|
|
|
2013-07-09 17:53:37 +08:00
|
|
|
DECLARE_REAL_AND_INTERCEPTOR(void *, malloc, uptr)
|
|
|
|
DECLARE_REAL_AND_INTERCEPTOR(void, free, void *)
|
|
|
|
|
2014-12-06 04:26:09 +08:00
|
|
|
#define ASAN_INTERCEPTOR_ENTER(ctx, func) \
|
|
|
|
AsanInterceptorContext _ctx = {#func}; \
|
|
|
|
ctx = (void *)&_ctx; \
|
|
|
|
(void) ctx; \
|
|
|
|
|
2013-11-11 19:28:30 +08:00
|
|
|
#define COMMON_INTERCEPT_FUNCTION(name) ASAN_INTERCEPT_FUNC(name)
|
2016-04-28 05:24:21 +08:00
|
|
|
#define COMMON_INTERCEPT_FUNCTION_VER(name, ver) \
|
|
|
|
ASAN_INTERCEPT_FUNC_VER(name, ver)
|
2013-01-18 21:12:56 +08:00
|
|
|
#define COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, size) \
|
2014-12-06 04:26:09 +08:00
|
|
|
ASAN_WRITE_RANGE(ctx, ptr, size)
|
|
|
|
#define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) \
|
|
|
|
ASAN_READ_RANGE(ctx, ptr, size)
|
2014-05-14 22:03:31 +08:00
|
|
|
#define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \
|
2015-01-28 06:50:19 +08:00
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, func); \
|
2014-05-14 22:03:31 +08:00
|
|
|
do { \
|
|
|
|
if (asan_init_is_running) \
|
|
|
|
return REAL(func)(__VA_ARGS__); \
|
|
|
|
if (SANITIZER_MAC && UNLIKELY(!asan_inited)) \
|
|
|
|
return REAL(func)(__VA_ARGS__); \
|
|
|
|
ENSURE_ASAN_INITED(); \
|
2013-05-29 17:09:58 +08:00
|
|
|
} while (false)
|
2015-01-21 16:54:01 +08:00
|
|
|
#define COMMON_INTERCEPTOR_DIR_ACQUIRE(ctx, path) \
|
|
|
|
do { \
|
|
|
|
} while (false)
|
2013-05-29 17:09:58 +08:00
|
|
|
#define COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd) \
|
|
|
|
do { \
|
|
|
|
} while (false)
|
|
|
|
#define COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd) \
|
|
|
|
do { \
|
|
|
|
} while (false)
|
|
|
|
#define COMMON_INTERCEPTOR_FD_SOCKET_ACCEPT(ctx, fd, newfd) \
|
|
|
|
do { \
|
2013-01-18 21:12:56 +08:00
|
|
|
} while (false)
|
2013-01-18 19:17:23 +08:00
|
|
|
#define COMMON_INTERCEPTOR_SET_THREAD_NAME(ctx, name) SetThreadName(name)
|
2013-11-15 00:48:22 +08:00
|
|
|
// Should be asanThreadRegistry().SetThreadNameByUserId(thread, name)
|
|
|
|
// But asan does not remember UserId's for threads (pthread_t);
|
|
|
|
// and remembers all ever existed threads, so the linear search by UserId
|
|
|
|
// can be slow.
|
2013-10-29 18:30:39 +08:00
|
|
|
#define COMMON_INTERCEPTOR_SET_PTHREAD_NAME(ctx, thread, name) \
|
2013-11-15 00:48:22 +08:00
|
|
|
do { \
|
|
|
|
} while (false)
|
2013-08-12 21:19:53 +08:00
|
|
|
#define COMMON_INTERCEPTOR_BLOCK_REAL(name) REAL(name)
|
2015-02-24 08:37:27 +08:00
|
|
|
// Strict init-order checking is dlopen-hostile:
|
2015-12-05 01:37:40 +08:00
|
|
|
// https://github.com/google/sanitizers/issues/178
|
2015-02-24 08:37:27 +08:00
|
|
|
#define COMMON_INTERCEPTOR_ON_DLOPEN(filename, flag) \
|
2017-03-09 18:47:38 +08:00
|
|
|
do { \
|
|
|
|
if (flags()->strict_init_order) \
|
|
|
|
StopInitOrderChecking(); \
|
|
|
|
CheckNoDeepBind(filename, flag); \
|
|
|
|
} while (false)
|
2013-10-03 23:22:29 +08:00
|
|
|
#define COMMON_INTERCEPTOR_ON_EXIT(ctx) OnExit()
|
2017-06-02 08:17:54 +08:00
|
|
|
#define COMMON_INTERCEPTOR_LIBRARY_LOADED(filename, handle)
|
|
|
|
#define COMMON_INTERCEPTOR_LIBRARY_UNLOADED()
|
2014-07-25 20:45:36 +08:00
|
|
|
#define COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED (!asan_inited)
|
2015-05-16 08:34:15 +08:00
|
|
|
#define COMMON_INTERCEPTOR_GET_TLS_RANGE(begin, end) \
|
|
|
|
if (AsanThread *t = GetCurrentThread()) { \
|
|
|
|
*begin = t->tls_begin(); \
|
|
|
|
*end = t->tls_end(); \
|
|
|
|
} else { \
|
|
|
|
*begin = *end = 0; \
|
|
|
|
}
|
2016-12-23 06:02:26 +08:00
|
|
|
|
|
|
|
#define COMMON_INTERCEPTOR_MEMMOVE_IMPL(ctx, to, from, size) \
|
|
|
|
do { \
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, memmove); \
|
|
|
|
ASAN_MEMMOVE_IMPL(ctx, to, from, size); \
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
#define COMMON_INTERCEPTOR_MEMCPY_IMPL(ctx, to, from, size) \
|
|
|
|
do { \
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, memcpy); \
|
2016-12-28 05:13:11 +08:00
|
|
|
ASAN_MEMCPY_IMPL(ctx, to, from, size); \
|
2016-12-23 06:02:26 +08:00
|
|
|
} while (false)
|
|
|
|
|
|
|
|
#define COMMON_INTERCEPTOR_MEMSET_IMPL(ctx, block, c, size) \
|
|
|
|
do { \
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, memset); \
|
|
|
|
ASAN_MEMSET_IMPL(ctx, block, c, size); \
|
|
|
|
} while (false)
|
|
|
|
|
2013-01-18 21:01:18 +08:00
|
|
|
#include "sanitizer_common/sanitizer_common_interceptors.inc"
|
2017-09-16 15:16:29 +08:00
|
|
|
#include "sanitizer_common/sanitizer_signal_interceptors.inc"
|
2012-12-12 17:54:35 +08:00
|
|
|
|
2014-12-06 04:26:09 +08:00
|
|
|
// Syscall interceptors don't have contexts, we don't support suppressions
|
|
|
|
// for them.
|
|
|
|
#define COMMON_SYSCALL_PRE_READ_RANGE(p, s) ASAN_READ_RANGE(nullptr, p, s)
|
|
|
|
#define COMMON_SYSCALL_PRE_WRITE_RANGE(p, s) ASAN_WRITE_RANGE(nullptr, p, s)
|
2013-07-09 17:29:19 +08:00
|
|
|
#define COMMON_SYSCALL_POST_READ_RANGE(p, s) \
|
|
|
|
do { \
|
2013-10-30 02:29:39 +08:00
|
|
|
(void)(p); \
|
|
|
|
(void)(s); \
|
2013-07-09 17:29:19 +08:00
|
|
|
} while (false)
|
|
|
|
#define COMMON_SYSCALL_POST_WRITE_RANGE(p, s) \
|
|
|
|
do { \
|
2013-10-30 02:29:39 +08:00
|
|
|
(void)(p); \
|
|
|
|
(void)(s); \
|
2013-07-09 17:29:19 +08:00
|
|
|
} while (false)
|
2013-04-12 22:57:03 +08:00
|
|
|
#include "sanitizer_common/sanitizer_common_syscalls.inc"
|
|
|
|
|
2014-12-05 08:10:15 +08:00
|
|
|
struct ThreadStartParam {
|
|
|
|
atomic_uintptr_t t;
|
|
|
|
atomic_uintptr_t is_registered;
|
|
|
|
};
|
|
|
|
|
2016-04-02 01:09:12 +08:00
|
|
|
#if ASAN_INTERCEPT_PTHREAD_CREATE
|
2012-02-24 23:28:43 +08:00
|
|
|
static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
|
2014-12-05 08:10:15 +08:00
|
|
|
ThreadStartParam *param = reinterpret_cast<ThreadStartParam *>(arg);
|
|
|
|
AsanThread *t = nullptr;
|
|
|
|
while ((t = reinterpret_cast<AsanThread *>(
|
2015-10-01 08:22:21 +08:00
|
|
|
atomic_load(¶m->t, memory_order_acquire))) == nullptr)
|
2014-12-05 08:10:15 +08:00
|
|
|
internal_sched_yield();
|
2013-03-20 17:23:28 +08:00
|
|
|
SetCurrentThread(t);
|
2014-12-05 08:10:15 +08:00
|
|
|
return t->ThreadStart(GetTid(), ¶m->is_registered);
|
2012-01-10 02:53:15 +08:00
|
|
|
}
|
|
|
|
|
2012-02-22 20:31:25 +08:00
|
|
|
INTERCEPTOR(int, pthread_create, void *thread,
|
|
|
|
void *attr, void *(*start_routine)(void*), void *arg) {
|
2013-07-08 20:57:24 +08:00
|
|
|
EnsureMainThreadIDIsCorrect();
|
2014-12-05 08:10:15 +08:00
|
|
|
// Strict init-order checking is thread-hostile.
|
2013-07-02 00:16:41 +08:00
|
|
|
if (flags()->strict_init_order)
|
|
|
|
StopInitOrderChecking();
|
2012-12-13 17:34:23 +08:00
|
|
|
GET_STACK_TRACE_THREAD;
|
2013-03-21 19:23:41 +08:00
|
|
|
int detached = 0;
|
2015-10-01 08:22:21 +08:00
|
|
|
if (attr)
|
2013-11-11 16:56:49 +08:00
|
|
|
REAL(pthread_attr_getdetachstate)(attr, &detached);
|
2014-12-05 08:10:15 +08:00
|
|
|
ThreadStartParam param;
|
|
|
|
atomic_store(¶m.t, 0, memory_order_relaxed);
|
|
|
|
atomic_store(¶m.is_registered, 0, memory_order_relaxed);
|
2016-01-16 08:57:25 +08:00
|
|
|
int result;
|
|
|
|
{
|
|
|
|
// Ignore all allocations made by pthread_create: thread stack/TLS may be
|
|
|
|
// stored by pthread for future reuse even after thread destruction, and
|
|
|
|
// the linked list it's stored in doesn't even hold valid pointers to the
|
|
|
|
// objects, the latter are calculated by obscure pointer arithmetic.
|
|
|
|
#if CAN_SANITIZE_LEAKS
|
|
|
|
__lsan::ScopedInterceptorDisabler disabler;
|
|
|
|
#endif
|
|
|
|
result = REAL(pthread_create)(thread, attr, asan_thread_start, ¶m);
|
|
|
|
}
|
2014-12-05 08:10:15 +08:00
|
|
|
if (result == 0) {
|
|
|
|
u32 current_tid = GetCurrentTidOrInvalid();
|
2014-12-06 01:31:13 +08:00
|
|
|
AsanThread *t =
|
|
|
|
AsanThread::Create(start_routine, arg, current_tid, &stack, detached);
|
2014-12-05 08:10:15 +08:00
|
|
|
atomic_store(¶m.t, reinterpret_cast<uptr>(t), memory_order_release);
|
|
|
|
// Wait until the AsanThread object is initialized and the ThreadRegistry
|
|
|
|
// entry is in "started" state. One reason for this is that after this
|
|
|
|
// interceptor exits, the child thread's stack may be the only thing holding
|
|
|
|
// the |arg| pointer. This may cause LSan to report a leak if leak checking
|
|
|
|
// happens at a point when the interceptor has already exited, but the stack
|
|
|
|
// range for the child thread is not yet known.
|
|
|
|
while (atomic_load(¶m.is_registered, memory_order_acquire) == 0)
|
|
|
|
internal_sched_yield();
|
|
|
|
}
|
|
|
|
return result;
|
2012-01-10 02:53:15 +08:00
|
|
|
}
|
2014-12-17 03:13:01 +08:00
|
|
|
|
|
|
|
INTERCEPTOR(int, pthread_join, void *t, void **arg) {
|
|
|
|
return real_pthread_join(t, arg);
|
|
|
|
}
|
2015-01-13 01:03:02 +08:00
|
|
|
|
|
|
|
DEFINE_REAL_PTHREAD_FUNCTIONS
|
2012-08-01 19:17:00 +08:00
|
|
|
#endif // ASAN_INTERCEPT_PTHREAD_CREATE
|
2012-01-10 02:53:15 +08:00
|
|
|
|
2012-11-23 17:46:34 +08:00
|
|
|
#if ASAN_INTERCEPT_SWAPCONTEXT
|
2013-01-17 23:45:28 +08:00
|
|
|
static void ClearShadowMemoryForContextStack(uptr stack, uptr ssize) {
|
|
|
|
// Align to page size.
|
|
|
|
uptr PageSize = GetPageSizeCached();
|
|
|
|
uptr bottom = stack & ~(PageSize - 1);
|
|
|
|
ssize += stack - bottom;
|
|
|
|
ssize = RoundUpTo(ssize, PageSize);
|
|
|
|
static const uptr kMaxSaneContextStackSize = 1 << 22; // 4 Mb
|
2015-03-28 04:40:23 +08:00
|
|
|
if (AddrIsInMem(bottom) && ssize && ssize <= kMaxSaneContextStackSize) {
|
2013-01-17 23:45:28 +08:00
|
|
|
PoisonShadow(bottom, ssize, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-23 17:46:34 +08:00
|
|
|
INTERCEPTOR(int, swapcontext, struct ucontext_t *oucp,
|
|
|
|
struct ucontext_t *ucp) {
|
|
|
|
static bool reported_warning = false;
|
|
|
|
if (!reported_warning) {
|
|
|
|
Report("WARNING: ASan doesn't fully support makecontext/swapcontext "
|
|
|
|
"functions and may produce false positives in some cases!\n");
|
|
|
|
reported_warning = true;
|
|
|
|
}
|
|
|
|
// Clear shadow memory for new context (it may share stack
|
|
|
|
// with current context).
|
2013-01-17 23:45:28 +08:00
|
|
|
uptr stack, ssize;
|
|
|
|
ReadContextStack(ucp, &stack, &ssize);
|
|
|
|
ClearShadowMemoryForContextStack(stack, ssize);
|
2012-11-23 17:46:34 +08:00
|
|
|
int res = REAL(swapcontext)(oucp, ucp);
|
|
|
|
// swapcontext technically does not return, but program may swap context to
|
|
|
|
// "oucp" later, that would look as if swapcontext() returned 0.
|
|
|
|
// We need to clear shadow for ucp once again, as it may be in arbitrary
|
|
|
|
// state.
|
2013-01-17 23:45:28 +08:00
|
|
|
ClearShadowMemoryForContextStack(stack, ssize);
|
2012-11-23 17:46:34 +08:00
|
|
|
return res;
|
|
|
|
}
|
2013-01-17 23:45:28 +08:00
|
|
|
#endif // ASAN_INTERCEPT_SWAPCONTEXT
|
2012-11-23 17:46:34 +08:00
|
|
|
|
2017-08-09 03:09:48 +08:00
|
|
|
#if SANITIZER_NETBSD
|
|
|
|
#define longjmp __longjmp14
|
|
|
|
#define siglongjmp __siglongjmp14
|
|
|
|
#endif
|
|
|
|
|
2012-02-02 18:39:40 +08:00
|
|
|
INTERCEPTOR(void, longjmp, void *env, int val) {
|
2012-02-09 05:33:27 +08:00
|
|
|
__asan_handle_no_return();
|
2012-02-08 21:45:31 +08:00
|
|
|
REAL(longjmp)(env, val);
|
2012-01-10 02:53:15 +08:00
|
|
|
}
|
|
|
|
|
2012-08-01 19:17:00 +08:00
|
|
|
#if ASAN_INTERCEPT__LONGJMP
|
2012-02-02 18:39:40 +08:00
|
|
|
INTERCEPTOR(void, _longjmp, void *env, int val) {
|
2012-02-09 05:33:27 +08:00
|
|
|
__asan_handle_no_return();
|
2012-02-08 21:45:31 +08:00
|
|
|
REAL(_longjmp)(env, val);
|
2012-01-10 02:53:15 +08:00
|
|
|
}
|
2012-08-01 19:17:00 +08:00
|
|
|
#endif
|
2012-01-10 02:53:15 +08:00
|
|
|
|
2017-05-04 22:03:57 +08:00
|
|
|
#if ASAN_INTERCEPT___LONGJMP_CHK
|
|
|
|
INTERCEPTOR(void, __longjmp_chk, void *env, int val) {
|
|
|
|
__asan_handle_no_return();
|
|
|
|
REAL(__longjmp_chk)(env, val);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-01 19:17:00 +08:00
|
|
|
#if ASAN_INTERCEPT_SIGLONGJMP
|
2012-02-02 18:39:40 +08:00
|
|
|
INTERCEPTOR(void, siglongjmp, void *env, int val) {
|
2012-02-09 05:33:27 +08:00
|
|
|
__asan_handle_no_return();
|
2012-02-08 21:45:31 +08:00
|
|
|
REAL(siglongjmp)(env, val);
|
2012-01-10 02:53:15 +08:00
|
|
|
}
|
2012-02-22 21:59:49 +08:00
|
|
|
#endif
|
2012-01-10 02:53:15 +08:00
|
|
|
|
2012-08-01 19:17:00 +08:00
|
|
|
#if ASAN_INTERCEPT___CXA_THROW
|
2012-02-02 18:39:40 +08:00
|
|
|
INTERCEPTOR(void, __cxa_throw, void *a, void *b, void *c) {
|
2012-02-08 21:45:31 +08:00
|
|
|
CHECK(REAL(__cxa_throw));
|
2012-02-09 05:33:27 +08:00
|
|
|
__asan_handle_no_return();
|
2012-02-08 21:45:31 +08:00
|
|
|
REAL(__cxa_throw)(a, b, c);
|
2012-01-10 02:53:15 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-01 19:17:00 +08:00
|
|
|
#if ASAN_INTERCEPT_INDEX
|
|
|
|
# if ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX
|
2012-02-13 20:12:32 +08:00
|
|
|
INTERCEPTOR(char*, index, const char *string, int c)
|
2013-02-21 23:15:43 +08:00
|
|
|
ALIAS(WRAPPER_NAME(strchr));
|
2012-08-01 19:17:00 +08:00
|
|
|
# else
|
2013-03-19 22:33:38 +08:00
|
|
|
# if SANITIZER_MAC
|
2013-02-21 22:41:16 +08:00
|
|
|
DECLARE_REAL(char*, index, const char *string, int c)
|
|
|
|
OVERRIDE_FUNCTION(index, strchr);
|
|
|
|
# else
|
2013-06-10 22:17:08 +08:00
|
|
|
DEFINE_REAL(char*, index, const char *string, int c)
|
2013-02-21 22:41:16 +08:00
|
|
|
# endif
|
2012-08-01 19:17:00 +08:00
|
|
|
# endif
|
|
|
|
#endif // ASAN_INTERCEPT_INDEX
|
2011-12-28 10:24:50 +08:00
|
|
|
|
2012-08-02 18:25:46 +08:00
|
|
|
// For both strcat() and strncat() we need to check the validity of |to|
|
|
|
|
// argument irrespective of the |from| length.
|
2012-02-02 18:39:40 +08:00
|
|
|
INTERCEPTOR(char*, strcat, char *to, const char *from) { // NOLINT
|
2014-12-06 04:26:09 +08:00
|
|
|
void *ctx;
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, strcat); // NOLINT
|
2011-12-29 03:08:49 +08:00
|
|
|
ENSURE_ASAN_INITED();
|
2012-07-09 22:36:04 +08:00
|
|
|
if (flags()->replace_str) {
|
2012-05-31 22:35:53 +08:00
|
|
|
uptr from_length = REAL(strlen)(from);
|
2014-12-06 04:26:09 +08:00
|
|
|
ASAN_READ_RANGE(ctx, from, from_length + 1);
|
2012-08-02 18:25:46 +08:00
|
|
|
uptr to_length = REAL(strlen)(to);
|
2015-04-07 02:00:26 +08:00
|
|
|
ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length);
|
2014-12-06 04:26:09 +08:00
|
|
|
ASAN_WRITE_RANGE(ctx, to + to_length, from_length + 1);
|
2012-08-02 18:25:46 +08:00
|
|
|
// If the copying actually happens, the |from| string should not overlap
|
|
|
|
// with the resulting string starting at |to|, which has a length of
|
|
|
|
// to_length + from_length + 1.
|
2011-12-29 03:08:49 +08:00
|
|
|
if (from_length > 0) {
|
2012-08-02 18:25:46 +08:00
|
|
|
CHECK_RANGES_OVERLAP("strcat", to, from_length + to_length + 1,
|
|
|
|
from, from_length + 1);
|
2011-12-29 03:08:49 +08:00
|
|
|
}
|
|
|
|
}
|
2012-02-08 21:45:31 +08:00
|
|
|
return REAL(strcat)(to, from); // NOLINT
|
2011-12-29 03:08:49 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 21:27:46 +08:00
|
|
|
INTERCEPTOR(char*, strncat, char *to, const char *from, uptr size) {
|
2014-12-06 04:26:09 +08:00
|
|
|
void *ctx;
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, strncat);
|
2012-06-08 21:27:46 +08:00
|
|
|
ENSURE_ASAN_INITED();
|
2012-08-02 18:25:46 +08:00
|
|
|
if (flags()->replace_str) {
|
2012-06-15 21:09:52 +08:00
|
|
|
uptr from_length = MaybeRealStrnlen(from, size);
|
2012-08-02 18:25:46 +08:00
|
|
|
uptr copy_length = Min(size, from_length + 1);
|
2014-12-06 04:26:09 +08:00
|
|
|
ASAN_READ_RANGE(ctx, from, copy_length);
|
2012-06-08 21:27:46 +08:00
|
|
|
uptr to_length = REAL(strlen)(to);
|
2015-04-07 02:00:26 +08:00
|
|
|
ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length);
|
2014-12-06 04:26:09 +08:00
|
|
|
ASAN_WRITE_RANGE(ctx, to + to_length, from_length + 1);
|
2012-06-08 21:27:46 +08:00
|
|
|
if (from_length > 0) {
|
2012-08-02 18:25:46 +08:00
|
|
|
CHECK_RANGES_OVERLAP("strncat", to, to_length + copy_length + 1,
|
|
|
|
from, copy_length);
|
2012-06-08 21:27:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return REAL(strncat)(to, from, size);
|
|
|
|
}
|
|
|
|
|
2012-02-02 18:39:40 +08:00
|
|
|
INTERCEPTOR(char*, strcpy, char *to, const char *from) { // NOLINT
|
2014-12-06 04:26:09 +08:00
|
|
|
void *ctx;
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, strcpy); // NOLINT
|
2013-03-19 22:33:38 +08:00
|
|
|
#if SANITIZER_MAC
|
2014-05-14 22:03:31 +08:00
|
|
|
if (UNLIKELY(!asan_inited)) return REAL(strcpy)(to, from); // NOLINT
|
2012-08-17 17:00:08 +08:00
|
|
|
#endif
|
2011-11-30 09:07:02 +08:00
|
|
|
// strcpy is called from malloc_default_purgeable_zone()
|
|
|
|
// in __asan::ReplaceSystemAlloc() on Mac.
|
|
|
|
if (asan_init_is_running) {
|
2012-02-08 21:45:31 +08:00
|
|
|
return REAL(strcpy)(to, from); // NOLINT
|
2011-11-30 09:07:02 +08:00
|
|
|
}
|
2011-12-06 02:56:29 +08:00
|
|
|
ENSURE_ASAN_INITED();
|
2012-07-09 22:36:04 +08:00
|
|
|
if (flags()->replace_str) {
|
2012-05-31 22:35:53 +08:00
|
|
|
uptr from_size = REAL(strlen)(from) + 1;
|
2011-12-29 03:24:31 +08:00
|
|
|
CHECK_RANGES_OVERLAP("strcpy", to, from_size, from, from_size);
|
2014-12-06 04:26:09 +08:00
|
|
|
ASAN_READ_RANGE(ctx, from, from_size);
|
|
|
|
ASAN_WRITE_RANGE(ctx, to, from_size);
|
2011-11-30 09:07:02 +08:00
|
|
|
}
|
2012-02-08 21:45:31 +08:00
|
|
|
return REAL(strcpy)(to, from); // NOLINT
|
2011-11-30 09:07:02 +08:00
|
|
|
}
|
|
|
|
|
2012-02-02 18:39:40 +08:00
|
|
|
INTERCEPTOR(char*, strdup, const char *s) {
|
2014-12-06 04:26:09 +08:00
|
|
|
void *ctx;
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, strdup);
|
2014-05-14 22:03:31 +08:00
|
|
|
if (UNLIKELY(!asan_inited)) return internal_strdup(s);
|
2011-12-06 02:56:29 +08:00
|
|
|
ENSURE_ASAN_INITED();
|
2013-06-21 22:41:59 +08:00
|
|
|
uptr length = REAL(strlen)(s);
|
2012-07-09 22:36:04 +08:00
|
|
|
if (flags()->replace_str) {
|
2014-12-06 04:26:09 +08:00
|
|
|
ASAN_READ_RANGE(ctx, s, length + 1);
|
2011-11-30 09:07:02 +08:00
|
|
|
}
|
2013-06-21 22:41:59 +08:00
|
|
|
GET_STACK_TRACE_MALLOC;
|
|
|
|
void *new_mem = asan_malloc(length + 1, &stack);
|
|
|
|
REAL(memcpy)(new_mem, s, length + 1);
|
|
|
|
return reinterpret_cast<char*>(new_mem);
|
2011-11-30 09:07:02 +08:00
|
|
|
}
|
|
|
|
|
2016-04-21 06:45:23 +08:00
|
|
|
#if ASAN_INTERCEPT___STRDUP
|
|
|
|
INTERCEPTOR(char*, __strdup, const char *s) {
|
|
|
|
void *ctx;
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, strdup);
|
|
|
|
if (UNLIKELY(!asan_inited)) return internal_strdup(s);
|
|
|
|
ENSURE_ASAN_INITED();
|
|
|
|
uptr length = REAL(strlen)(s);
|
|
|
|
if (flags()->replace_str) {
|
|
|
|
ASAN_READ_RANGE(ctx, s, length + 1);
|
|
|
|
}
|
|
|
|
GET_STACK_TRACE_MALLOC;
|
|
|
|
void *new_mem = asan_malloc(length + 1, &stack);
|
|
|
|
REAL(memcpy)(new_mem, s, length + 1);
|
|
|
|
return reinterpret_cast<char*>(new_mem);
|
|
|
|
}
|
|
|
|
#endif // ASAN_INTERCEPT___STRDUP
|
|
|
|
|
2012-05-31 22:35:53 +08:00
|
|
|
INTERCEPTOR(char*, strncpy, char *to, const char *from, uptr size) {
|
2014-12-06 04:26:09 +08:00
|
|
|
void *ctx;
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, strncpy);
|
2011-12-06 02:56:29 +08:00
|
|
|
ENSURE_ASAN_INITED();
|
2012-07-09 22:36:04 +08:00
|
|
|
if (flags()->replace_str) {
|
2012-06-15 21:09:52 +08:00
|
|
|
uptr from_size = Min(size, MaybeRealStrnlen(from, size) + 1);
|
2011-12-29 03:24:31 +08:00
|
|
|
CHECK_RANGES_OVERLAP("strncpy", to, from_size, from, from_size);
|
2014-12-06 04:26:09 +08:00
|
|
|
ASAN_READ_RANGE(ctx, from, from_size);
|
|
|
|
ASAN_WRITE_RANGE(ctx, to, size);
|
2011-11-30 09:07:02 +08:00
|
|
|
}
|
2012-02-08 21:45:31 +08:00
|
|
|
return REAL(strncpy)(to, from, size);
|
2011-11-30 09:07:02 +08:00
|
|
|
}
|
|
|
|
|
2012-03-29 16:04:35 +08:00
|
|
|
INTERCEPTOR(long, strtol, const char *nptr, // NOLINT
|
2012-03-24 16:39:14 +08:00
|
|
|
char **endptr, int base) {
|
2014-12-06 04:26:09 +08:00
|
|
|
void *ctx;
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, strtol);
|
2012-03-24 16:39:14 +08:00
|
|
|
ENSURE_ASAN_INITED();
|
2012-07-09 22:36:04 +08:00
|
|
|
if (!flags()->replace_str) {
|
2012-03-29 16:04:35 +08:00
|
|
|
return REAL(strtol)(nptr, endptr, base);
|
2012-03-24 16:39:14 +08:00
|
|
|
}
|
|
|
|
char *real_endptr;
|
2012-03-29 16:04:35 +08:00
|
|
|
long result = REAL(strtol)(nptr, &real_endptr, base); // NOLINT
|
2015-04-07 02:00:26 +08:00
|
|
|
StrtolFixAndCheck(ctx, nptr, endptr, real_endptr, base);
|
2012-03-24 16:39:14 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-03-29 16:04:35 +08:00
|
|
|
INTERCEPTOR(int, atoi, const char *nptr) {
|
2014-12-06 04:26:09 +08:00
|
|
|
void *ctx;
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, atoi);
|
2013-03-19 22:33:38 +08:00
|
|
|
#if SANITIZER_MAC
|
2014-05-14 22:03:31 +08:00
|
|
|
if (UNLIKELY(!asan_inited)) return REAL(atoi)(nptr);
|
2012-08-17 17:00:08 +08:00
|
|
|
#endif
|
2012-03-29 16:04:35 +08:00
|
|
|
ENSURE_ASAN_INITED();
|
2012-07-09 22:36:04 +08:00
|
|
|
if (!flags()->replace_str) {
|
2012-03-29 16:04:35 +08:00
|
|
|
return REAL(atoi)(nptr);
|
|
|
|
}
|
|
|
|
char *real_endptr;
|
|
|
|
// "man atoi" tells that behavior of atoi(nptr) is the same as
|
2012-05-31 22:35:53 +08:00
|
|
|
// strtol(nptr, 0, 10), i.e. it sets errno to ERANGE if the
|
2012-03-29 16:04:35 +08:00
|
|
|
// parsed integer can't be stored in *long* type (even if it's
|
|
|
|
// different from int). So, we just imitate this behavior.
|
|
|
|
int result = REAL(strtol)(nptr, &real_endptr, 10);
|
|
|
|
FixRealStrtolEndptr(nptr, &real_endptr);
|
2015-04-07 02:00:26 +08:00
|
|
|
ASAN_READ_STRING(ctx, nptr, (real_endptr - nptr) + 1);
|
2012-03-29 16:04:35 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERCEPTOR(long, atol, const char *nptr) { // NOLINT
|
2014-12-06 04:26:09 +08:00
|
|
|
void *ctx;
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, atol);
|
2013-03-19 22:33:38 +08:00
|
|
|
#if SANITIZER_MAC
|
2014-05-14 22:03:31 +08:00
|
|
|
if (UNLIKELY(!asan_inited)) return REAL(atol)(nptr);
|
2012-08-17 17:00:08 +08:00
|
|
|
#endif
|
2012-03-29 16:04:35 +08:00
|
|
|
ENSURE_ASAN_INITED();
|
2012-07-09 22:36:04 +08:00
|
|
|
if (!flags()->replace_str) {
|
2012-03-29 16:04:35 +08:00
|
|
|
return REAL(atol)(nptr);
|
|
|
|
}
|
|
|
|
char *real_endptr;
|
|
|
|
long result = REAL(strtol)(nptr, &real_endptr, 10); // NOLINT
|
|
|
|
FixRealStrtolEndptr(nptr, &real_endptr);
|
2015-04-07 02:00:26 +08:00
|
|
|
ASAN_READ_STRING(ctx, nptr, (real_endptr - nptr) + 1);
|
2012-03-29 16:04:35 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if ASAN_INTERCEPT_ATOLL_AND_STRTOLL
|
|
|
|
INTERCEPTOR(long long, strtoll, const char *nptr, // NOLINT
|
2012-03-27 00:42:22 +08:00
|
|
|
char **endptr, int base) {
|
2014-12-06 04:26:09 +08:00
|
|
|
void *ctx;
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, strtoll);
|
2012-03-27 00:42:22 +08:00
|
|
|
ENSURE_ASAN_INITED();
|
2012-07-09 22:36:04 +08:00
|
|
|
if (!flags()->replace_str) {
|
2012-03-29 16:04:35 +08:00
|
|
|
return REAL(strtoll)(nptr, endptr, base);
|
2012-03-27 00:42:22 +08:00
|
|
|
}
|
|
|
|
char *real_endptr;
|
2012-03-29 16:04:35 +08:00
|
|
|
long long result = REAL(strtoll)(nptr, &real_endptr, base); // NOLINT
|
2015-04-07 02:00:26 +08:00
|
|
|
StrtolFixAndCheck(ctx, nptr, endptr, real_endptr, base);
|
2012-03-27 00:42:22 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-03-29 16:04:35 +08:00
|
|
|
INTERCEPTOR(long long, atoll, const char *nptr) { // NOLINT
|
2014-12-06 04:26:09 +08:00
|
|
|
void *ctx;
|
|
|
|
ASAN_INTERCEPTOR_ENTER(ctx, atoll);
|
2012-03-29 16:04:35 +08:00
|
|
|
ENSURE_ASAN_INITED();
|
2012-07-09 22:36:04 +08:00
|
|
|
if (!flags()->replace_str) {
|
2012-03-29 16:04:35 +08:00
|
|
|
return REAL(atoll)(nptr);
|
|
|
|
}
|
|
|
|
char *real_endptr;
|
|
|
|
long long result = REAL(strtoll)(nptr, &real_endptr, 10); // NOLINT
|
|
|
|
FixRealStrtolEndptr(nptr, &real_endptr);
|
2015-04-07 02:00:26 +08:00
|
|
|
ASAN_READ_STRING(ctx, nptr, (real_endptr - nptr) + 1);
|
2012-03-29 16:04:35 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
#endif // ASAN_INTERCEPT_ATOLL_AND_STRTOLL
|
|
|
|
|
2016-04-02 01:09:12 +08:00
|
|
|
#if ASAN_INTERCEPT___CXA_ATEXIT
|
2013-05-24 19:46:56 +08:00
|
|
|
static void AtCxaAtexit(void *unused) {
|
|
|
|
(void)unused;
|
|
|
|
StopInitOrderChecking();
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
|
|
|
|
void *dso_handle) {
|
2013-11-13 21:34:53 +08:00
|
|
|
#if SANITIZER_MAC
|
2014-05-14 22:03:31 +08:00
|
|
|
if (UNLIKELY(!asan_inited)) return REAL(__cxa_atexit)(func, arg, dso_handle);
|
2013-11-13 21:34:53 +08:00
|
|
|
#endif
|
2013-05-24 19:46:56 +08:00
|
|
|
ENSURE_ASAN_INITED();
|
|
|
|
int res = REAL(__cxa_atexit)(func, arg, dso_handle);
|
2015-10-01 08:22:21 +08:00
|
|
|
REAL(__cxa_atexit)(AtCxaAtexit, nullptr, nullptr);
|
2013-05-24 19:46:56 +08:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
#endif // ASAN_INTERCEPT___CXA_ATEXIT
|
|
|
|
|
2014-06-04 20:13:54 +08:00
|
|
|
#if ASAN_INTERCEPT_FORK
|
|
|
|
INTERCEPTOR(int, fork, void) {
|
|
|
|
ENSURE_ASAN_INITED();
|
|
|
|
int pid = REAL(fork)();
|
|
|
|
return pid;
|
|
|
|
}
|
|
|
|
#endif // ASAN_INTERCEPT_FORK
|
|
|
|
|
2012-01-10 03:35:11 +08:00
|
|
|
// ---------------------- InitializeAsanInterceptors ---------------- {{{1
|
|
|
|
namespace __asan {
|
|
|
|
void InitializeAsanInterceptors() {
|
2012-03-17 05:02:13 +08:00
|
|
|
static bool was_called_once;
|
2016-08-03 23:47:40 +08:00
|
|
|
CHECK(!was_called_once);
|
2012-03-17 05:02:13 +08:00
|
|
|
was_called_once = true;
|
2014-05-07 21:24:28 +08:00
|
|
|
InitializeCommonInterceptors();
|
2017-09-16 15:16:29 +08:00
|
|
|
InitializeSignalInterceptors();
|
2012-12-12 17:54:35 +08:00
|
|
|
|
2012-02-22 21:59:49 +08:00
|
|
|
// Intercept str* functions.
|
2012-05-24 21:54:31 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(strcat); // NOLINT
|
|
|
|
ASAN_INTERCEPT_FUNC(strcpy); // NOLINT
|
2012-06-08 21:27:46 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(strncat);
|
2012-05-24 21:54:31 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(strncpy);
|
2012-08-01 19:17:00 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(strdup);
|
2016-04-21 06:45:23 +08:00
|
|
|
#if ASAN_INTERCEPT___STRDUP
|
|
|
|
ASAN_INTERCEPT_FUNC(__strdup);
|
|
|
|
#endif
|
2013-02-05 23:57:12 +08:00
|
|
|
#if ASAN_INTERCEPT_INDEX && ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX
|
2012-05-24 21:54:31 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(index);
|
2012-02-22 21:59:49 +08:00
|
|
|
#endif
|
2012-02-09 03:52:01 +08:00
|
|
|
|
2012-05-24 21:54:31 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(atoi);
|
|
|
|
ASAN_INTERCEPT_FUNC(atol);
|
|
|
|
ASAN_INTERCEPT_FUNC(strtol);
|
2012-03-29 16:04:35 +08:00
|
|
|
#if ASAN_INTERCEPT_ATOLL_AND_STRTOLL
|
2012-05-24 21:54:31 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(atoll);
|
|
|
|
ASAN_INTERCEPT_FUNC(strtoll);
|
2012-03-24 16:39:14 +08:00
|
|
|
#endif
|
|
|
|
|
2017-09-16 15:16:29 +08:00
|
|
|
// Intecept jump-related functions.
|
2012-05-24 21:54:31 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(longjmp);
|
2017-09-16 15:16:29 +08:00
|
|
|
|
2012-11-23 17:46:34 +08:00
|
|
|
#if ASAN_INTERCEPT_SWAPCONTEXT
|
|
|
|
ASAN_INTERCEPT_FUNC(swapcontext);
|
|
|
|
#endif
|
2012-08-01 19:17:00 +08:00
|
|
|
#if ASAN_INTERCEPT__LONGJMP
|
2012-05-24 21:54:31 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(_longjmp);
|
2012-08-01 19:17:00 +08:00
|
|
|
#endif
|
2017-05-04 22:03:57 +08:00
|
|
|
#if ASAN_INTERCEPT___LONGJMP_CHK
|
|
|
|
ASAN_INTERCEPT_FUNC(__longjmp_chk);
|
|
|
|
#endif
|
2012-08-01 19:17:00 +08:00
|
|
|
#if ASAN_INTERCEPT_SIGLONGJMP
|
2012-05-24 21:54:31 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(siglongjmp);
|
2012-08-01 19:17:00 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Intercept exception handling functions.
|
|
|
|
#if ASAN_INTERCEPT___CXA_THROW
|
2014-08-21 21:33:39 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(__cxa_throw);
|
2012-02-10 01:20:14 +08:00
|
|
|
#endif
|
|
|
|
|
2012-02-22 21:59:49 +08:00
|
|
|
// Intercept threading-related functions
|
2012-08-01 19:17:00 +08:00
|
|
|
#if ASAN_INTERCEPT_PTHREAD_CREATE
|
2015-09-23 05:34:44 +08:00
|
|
|
#if defined(ASAN_PTHREAD_CREATE_VERSION)
|
|
|
|
ASAN_INTERCEPT_FUNC_VER(pthread_create, ASAN_PTHREAD_CREATE_VERSION);
|
|
|
|
#else
|
2012-05-24 21:54:31 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(pthread_create);
|
2015-09-23 05:34:44 +08:00
|
|
|
#endif
|
2014-12-17 03:13:01 +08:00
|
|
|
ASAN_INTERCEPT_FUNC(pthread_join);
|
2012-02-22 21:59:49 +08:00
|
|
|
#endif
|
|
|
|
|
2013-05-24 19:46:56 +08:00
|
|
|
// Intercept atexit function.
|
|
|
|
#if ASAN_INTERCEPT___CXA_ATEXIT
|
|
|
|
ASAN_INTERCEPT_FUNC(__cxa_atexit);
|
|
|
|
#endif
|
|
|
|
|
2014-06-04 20:13:54 +08:00
|
|
|
#if ASAN_INTERCEPT_FORK
|
|
|
|
ASAN_INTERCEPT_FUNC(fork);
|
|
|
|
#endif
|
|
|
|
|
2015-03-16 22:22:53 +08:00
|
|
|
InitializePlatformInterceptors();
|
2012-02-24 23:28:43 +08:00
|
|
|
|
2013-12-05 20:04:51 +08:00
|
|
|
VReport(1, "AddressSanitizer: libc interceptors initialized\n");
|
2012-01-10 03:35:11 +08:00
|
|
|
}
|
|
|
|
|
2015-10-01 08:22:21 +08:00
|
|
|
} // namespace __asan
|
2017-08-02 15:59:30 +08:00
|
|
|
|
|
|
|
#endif // !SANITIZER_FUCHSIA
|