#include "hwasan.h"
#include "hwasan_checks.h"
#include "hwasan_dynamic_shadow.h"
#include "hwasan_globals.h"
#include "hwasan_mapping.h"
#include "hwasan_poisoning.h"
#include "hwasan_report.h"
#include "hwasan_thread.h"
#include "hwasan_thread_list.h"
#include "sanitizer_common/sanitizer_atomic.h"
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_flag_parser.h"
#include "sanitizer_common/sanitizer_flags.h"
#include "sanitizer_common/sanitizer_interface_internal.h"
#include "sanitizer_common/sanitizer_libc.h"
#include "sanitizer_common/sanitizer_procmaps.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
#include "sanitizer_common/sanitizer_stacktrace.h"
#include "sanitizer_common/sanitizer_symbolizer.h"
#include "ubsan/ubsan_flags.h"
#include "ubsan/ubsan_init.h"
usingnamespace__sanitizer;
namespace __hwasan {
static Flags hwasan_flags;
Flags *flags() { … }
int hwasan_inited = …;
int hwasan_instrumentation_inited = …;
bool hwasan_init_is_running;
int hwasan_report_count = …;
uptr kLowShadowStart;
uptr kLowShadowEnd;
uptr kHighShadowStart;
uptr kHighShadowEnd;
void Flags::SetDefaults() { … }
static void RegisterHwasanFlags(FlagParser *parser, Flags *f) { … }
static void InitializeFlags() { … }
static void CheckUnwind() { … }
static void HwasanFormatMemoryUsage(InternalScopedString &s) { … }
#if SANITIZER_ANDROID
static constexpr uptr kMemoryUsageBufferSize = 4096;
static char *memory_usage_buffer = nullptr;
static void InitMemoryUsage() {
memory_usage_buffer =
(char *)MmapOrDie(kMemoryUsageBufferSize, "memory usage string");
CHECK(memory_usage_buffer);
memory_usage_buffer[0] = '\0';
DecorateMapping((uptr)memory_usage_buffer, kMemoryUsageBufferSize,
memory_usage_buffer);
}
void UpdateMemoryUsage() {
if (!flags()->export_memory_stats)
return;
if (!memory_usage_buffer)
InitMemoryUsage();
InternalScopedString s;
HwasanFormatMemoryUsage(s);
internal_strncpy(memory_usage_buffer, s.data(), kMemoryUsageBufferSize - 1);
memory_usage_buffer[kMemoryUsageBufferSize - 1] = '\0';
}
#else
void UpdateMemoryUsage() { … }
#endif
void HwasanAtExit() { … }
void HandleTagMismatch(AccessInfo ai, uptr pc, uptr frame, void *uc,
uptr *registers_frame) { … }
void HwasanTagMismatch(uptr addr, uptr pc, uptr frame, uptr access_info,
uptr *registers_frame, size_t outsize) { … }
Thread *GetCurrentThread() { … }
}
usingnamespace__hwasan;
void __sanitizer::BufferedStackTrace::UnwindImpl(
uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) { … }
static bool InitializeSingleGlobal(const hwasan_global &global) { … }
static void InitLoadedGlobals() { … }
static void InitInstrumentation() { … }
uptr __hwasan_shadow_memory_dynamic_address;
void __hwasan_init_frames(uptr beg, uptr end) { … }
void __hwasan_init_static() { … }
__attribute__((constructor(0))) void __hwasan_init() { … }
void __hwasan_library_loaded(ElfW(Addr) base, const ElfW(Phdr) * phdr,
ElfW(Half) phnum) { … }
void __hwasan_library_unloaded(ElfW(Addr) base, const ElfW(Phdr) * phdr,
ElfW(Half) phnum) { … }
void __hwasan_print_shadow(const void *p, uptr sz) { … }
sptr __hwasan_test_shadow(const void *p, uptr sz) { … }
u16 __sanitizer_unaligned_load16(const uu16 *p) { … }
u32 __sanitizer_unaligned_load32(const uu32 *p) { … }
u64 __sanitizer_unaligned_load64(const uu64 *p) { … }
void __sanitizer_unaligned_store16(uu16 *p, u16 x) { … }
void __sanitizer_unaligned_store32(uu32 *p, u32 x) { … }
void __sanitizer_unaligned_store64(uu64 *p, u64 x) { … }
void __hwasan_loadN(uptr p, uptr sz) { … }
void __hwasan_load1(uptr p) { … }
void __hwasan_load2(uptr p) { … }
void __hwasan_load4(uptr p) { … }
void __hwasan_load8(uptr p) { … }
void __hwasan_load16(uptr p) { … }
void __hwasan_loadN_noabort(uptr p, uptr sz) { … }
void __hwasan_load1_noabort(uptr p) { … }
void __hwasan_load2_noabort(uptr p) { … }
void __hwasan_load4_noabort(uptr p) { … }
void __hwasan_load8_noabort(uptr p) { … }
void __hwasan_load16_noabort(uptr p) { … }
void __hwasan_loadN_match_all(uptr p, uptr sz, u8 match_all_tag) { … }
void __hwasan_load1_match_all(uptr p, u8 match_all_tag) { … }
void __hwasan_load2_match_all(uptr p, u8 match_all_tag) { … }
void __hwasan_load4_match_all(uptr p, u8 match_all_tag) { … }
void __hwasan_load8_match_all(uptr p, u8 match_all_tag) { … }
void __hwasan_load16_match_all(uptr p, u8 match_all_tag) { … }
void __hwasan_loadN_match_all_noabort(uptr p, uptr sz, u8 match_all_tag) { … }
void __hwasan_load1_match_all_noabort(uptr p, u8 match_all_tag) { … }
void __hwasan_load2_match_all_noabort(uptr p, u8 match_all_tag) { … }
void __hwasan_load4_match_all_noabort(uptr p, u8 match_all_tag) { … }
void __hwasan_load8_match_all_noabort(uptr p, u8 match_all_tag) { … }
void __hwasan_load16_match_all_noabort(uptr p, u8 match_all_tag) { … }
void __hwasan_storeN(uptr p, uptr sz) { … }
void __hwasan_store1(uptr p) { … }
void __hwasan_store2(uptr p) { … }
void __hwasan_store4(uptr p) { … }
void __hwasan_store8(uptr p) { … }
void __hwasan_store16(uptr p) { … }
void __hwasan_storeN_noabort(uptr p, uptr sz) { … }
void __hwasan_store1_noabort(uptr p) { … }
void __hwasan_store2_noabort(uptr p) { … }
void __hwasan_store4_noabort(uptr p) { … }
void __hwasan_store8_noabort(uptr p) { … }
void __hwasan_store16_noabort(uptr p) { … }
void __hwasan_storeN_match_all(uptr p, uptr sz, u8 match_all_tag) { … }
void __hwasan_store1_match_all(uptr p, u8 match_all_tag) { … }
void __hwasan_store2_match_all(uptr p, u8 match_all_tag) { … }
void __hwasan_store4_match_all(uptr p, u8 match_all_tag) { … }
void __hwasan_store8_match_all(uptr p, u8 match_all_tag) { … }
void __hwasan_store16_match_all(uptr p, u8 match_all_tag) { … }
void __hwasan_storeN_match_all_noabort(uptr p, uptr sz, u8 match_all_tag) { … }
void __hwasan_store1_match_all_noabort(uptr p, u8 match_all_tag) { … }
void __hwasan_store2_match_all_noabort(uptr p, u8 match_all_tag) { … }
void __hwasan_store4_match_all_noabort(uptr p, u8 match_all_tag) { … }
void __hwasan_store8_match_all_noabort(uptr p, u8 match_all_tag) { … }
void __hwasan_store16_match_all_noabort(uptr p, u8 match_all_tag) { … }
void __hwasan_tag_memory(uptr p, u8 tag, uptr sz) { … }
uptr __hwasan_tag_pointer(uptr p, u8 tag) { … }
u8 __hwasan_get_tag_from_pointer(uptr p) { … }
void __hwasan_handle_longjmp(const void *sp_dst) { … }
void __hwasan_handle_vfork(const void *sp_dst) { … }
extern "C" void *__hwasan_extra_spill_area() { … }
void __hwasan_print_memory_usage() { … }
static const u8 kFallbackTag = …;
u8 __hwasan_generate_tag() { … }
void __hwasan_add_frame_record(u64 frame_record_info) { … }
#if !SANITIZER_SUPPORTS_WEAK_HOOKS
extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
const char* __hwasan_default_options() { return ""; }
}
#endif
extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE
void __sanitizer_print_stack_trace() { … }
void __hwasan_tag_mismatch4(uptr addr, uptr access_info, uptr *registers_frame,
size_t outsize) { … }
}