#define SANITIZER_COMMON_NO_REDEFINE_BUILTINS
#include "hwasan.h"
#include "hwasan_allocator.h"
#include "hwasan_checks.h"
#include "hwasan_mapping.h"
#include "hwasan_platform_interceptors.h"
#include "hwasan_thread.h"
#include "hwasan_thread_list.h"
#include "interception/interception.h"
#include "sanitizer_common/sanitizer_errno.h"
#include "sanitizer_common/sanitizer_linux.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
#if !SANITIZER_FUCHSIA
usingnamespace__hwasan;
struct HWAsanInterceptorContext { … };
#define ACCESS_MEMORY_RANGE(offset, size, access) …
#define HWASAN_READ_RANGE(offset, size) …
#define HWASAN_WRITE_RANGE(offset, size) …
# if !SANITIZER_APPLE
#define HWASAN_INTERCEPT_FUNC(name) …
#define HWASAN_INTERCEPT_FUNC_VER(name, ver) …
#define HWASAN_INTERCEPT_FUNC_VER_UNVERSIONED_FALLBACK(name, ver) …
# else
#define HWASAN_INTERCEPT_FUNC …
# endif
# if HWASAN_WITH_INTERCEPTORS
#define COMMON_SYSCALL_PRE_READ_RANGE(p, s) …
#define COMMON_SYSCALL_PRE_WRITE_RANGE(p, s) …
#define COMMON_SYSCALL_POST_READ_RANGE(p, s) …
#define COMMON_SYSCALL_POST_WRITE_RANGE(p, s) …
# include "sanitizer_common/sanitizer_common_syscalls.inc"
# include "sanitizer_common/sanitizer_syscalls_netbsd.inc"
#define COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, size) …
#define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) …
#define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) …
#define COMMON_INTERCEPTOR_DIR_ACQUIRE(ctx, path) …
#define COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd) …
#define COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd) …
#define COMMON_INTERCEPTOR_FD_SOCKET_ACCEPT(ctx, fd, newfd) …
#define COMMON_INTERCEPTOR_SET_THREAD_NAME(ctx, name) …
#define COMMON_INTERCEPTOR_SET_PTHREAD_NAME(ctx, thread, name) …
#define COMMON_INTERCEPTOR_BLOCK_REAL(name) …
#define COMMON_INTERCEPTOR_MEMSET_IMPL(ctx, dst, v, size) …
#define COMMON_INTERCEPTOR_STRERROR() …
#define COMMON_INTERCEPT_FUNCTION(name) …
#define COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED …
template <class Mmap>
static void *mmap_interceptor(Mmap real_mmap, void *addr, SIZE_T length,
int prot, int flags, int fd, OFF64_T offset) { … }
template <class Munmap>
static int munmap_interceptor(Munmap real_munmap, void *addr, SIZE_T length) { … }
#define COMMON_INTERCEPTOR_MMAP_IMPL(ctx, mmap, addr, length, prot, flags, \
fd, offset) …
#define COMMON_INTERCEPTOR_MUNMAP_IMPL(ctx, addr, length) …
# include "sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc"
# include "sanitizer_common/sanitizer_common_interceptors.inc"
struct ThreadStartArg { … };
static void *HwasanThreadStartFunc(void *arg) { … }
extern "C" {
int pthread_attr_getdetachstate(void *attr, int *v);
}
INTERCEPTOR(int, pthread_create, void *thread, void *attr,
void *(*callback)(void *), void *param) { … }
INTERCEPTOR(int, pthread_join, void *thread, void **retval) { … }
INTERCEPTOR(int, pthread_detach, void *thread) { … }
INTERCEPTOR(void, pthread_exit, void *retval) { … }
# if SANITIZER_GLIBC
INTERCEPTOR(int, pthread_tryjoin_np, void *thread, void **ret) { … }
INTERCEPTOR(int, pthread_timedjoin_np, void *thread, void **ret,
const struct timespec *abstime) { … }
# endif
DEFINE_INTERNAL_PTHREAD_FUNCTIONS
DEFINE_REAL(…)
DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(…)
extern "C" int sigprocmask(int __how, const __hw_sigset_t *__restrict __set,
__hw_sigset_t *__restrict __oset);
#define SIG_BLOCK …
#define SIG_SETMASK …
extern "C" int __sigjmp_save(__hw_sigjmp_buf env, int savemask) { … }
static void __attribute__((always_inline))
InternalLongjmp(__hw_register_buf env, int retval) { … }
INTERCEPTOR(void, siglongjmp, __hw_sigjmp_buf env, int val) { … }
INTERCEPTOR(void, __libc_longjmp, __hw_jmp_buf env, int val) { … }
INTERCEPTOR(void, longjmp, __hw_jmp_buf env, int val) { … }
# undef SIG_BLOCK
# undef SIG_SETMASK
# endif
namespace __hwasan {
int OnExit() { … }
}
namespace __hwasan {
void InitializeInterceptors() { … }
}
#endif