#include "dfsan/dfsan.h"
#include "dfsan/dfsan_chained_origin_depot.h"
#include "dfsan/dfsan_flags.h"
#include "dfsan/dfsan_origin.h"
#include "dfsan/dfsan_thread.h"
#include "sanitizer_common/sanitizer_atomic.h"
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_file.h"
#include "sanitizer_common/sanitizer_flag_parser.h"
#include "sanitizer_common/sanitizer_flags.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_common/sanitizer_libc.h"
#include "sanitizer_common/sanitizer_report_decorator.h"
#include "sanitizer_common/sanitizer_stacktrace.h"
#if SANITIZER_LINUX
# include <sys/personality.h>
#endif
usingnamespace__dfsan;
Flags __dfsan::flags_data;
static const int kDFsanArgTlsSize = …;
static const int kDFsanRetvalTlsSize = …;
static const int kDFsanArgOriginTlsSize = …;
SANITIZER_INTERFACE_ATTRIBUTE THREADLOCAL u64
__dfsan_retval_tls[kDFsanRetvalTlsSize / sizeof(u64)];
SANITIZER_INTERFACE_ATTRIBUTE THREADLOCAL u32 __dfsan_retval_origin_tls;
SANITIZER_INTERFACE_ATTRIBUTE THREADLOCAL u64
__dfsan_arg_tls[kDFsanArgTlsSize / sizeof(u64)];
SANITIZER_INTERFACE_ATTRIBUTE THREADLOCAL u32
__dfsan_arg_origin_tls[kDFsanArgOriginTlsSize / sizeof(u32)];
extern "C" SANITIZER_WEAK_ATTRIBUTE const int __dfsan_track_origins;
extern "C" SANITIZER_INTERFACE_ATTRIBUTE int dfsan_get_track_origins() { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE
dfsan_label __dfsan_union_load(const dfsan_label *ls, uptr n) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE u64
__dfsan_load_label_and_origin(const void *addr, uptr n) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE
void __dfsan_unimplemented(char *fname) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __dfsan_wrapper_extern_weak_null(
const void *addr, char *fname) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __dfsan_nonzero_label() { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
__dfsan_vararg_wrapper(const char *fname) { … }
SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
dfsan_union(dfsan_label l1, dfsan_label l2) { … }
static const uptr kOriginAlign = …;
static const uptr kOriginAlignMask = …;
static uptr OriginAlignUp(uptr u) { … }
static uptr OriginAlignDown(uptr u) { … }
static dfsan_origin GetOriginIfTainted(uptr addr, uptr size) { … }
#define GET_STORE_STACK_TRACE_PC_BP(pc, bp) …
#define PRINT_CALLER_STACK_TRACE …
static u32 ChainOrigin(u32 id, StackTrace *stack, bool from_init = false) { … }
static void ChainAndWriteOriginIfTainted(uptr src, uptr size, uptr dst,
StackTrace *stack) { … }
static void CopyOrigin(const void *dst, const void *src, uptr size,
StackTrace *stack) { … }
static void ReverseCopyOrigin(const void *dst, const void *src, uptr size,
StackTrace *stack) { … }
static void MoveOrigin(const void *dst, const void *src, uptr size,
StackTrace *stack) { … }
static void SetOrigin(const void *dst, uptr size, u32 origin) { … }
#define RET_CHAIN_ORIGIN(id) …
extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_origin
__dfsan_chain_origin(dfsan_origin id) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_origin
__dfsan_chain_origin_if_tainted(dfsan_label label, dfsan_origin id) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __dfsan_mem_origin_transfer(
const void *dst, const void *src, uptr len) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void dfsan_mem_origin_transfer(
const void *dst, const void *src, uptr len) { … }
static void CopyShadow(void *dst, const void *src, uptr len) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void dfsan_mem_shadow_transfer(
void *dst, const void *src, uptr len) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
__dfsan_mem_shadow_origin_transfer(void *dst, const void *src, uptr size) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
__dfsan_mem_shadow_origin_conditional_exchange(u8 condition, void *target,
void *expected,
const void *desired, uptr size) { … }
bool __dfsan::dfsan_inited;
bool __dfsan::dfsan_init_is_running;
void __dfsan::dfsan_copy_memory(void *dst, const void *src, uptr size) { … }
static void ReleaseOrigins(void *addr, uptr size) { … }
static void WriteZeroShadowInRange(uptr beg, uptr end) { … }
static void ReleaseOrClearShadows(void *addr, uptr size) { … }
static void SetShadow(dfsan_label label, void *addr, uptr size,
dfsan_origin origin) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __dfsan_maybe_store_origin(
dfsan_label s, void *p, uptr size, dfsan_origin o) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __dfsan_set_label(
dfsan_label label, dfsan_origin origin, void *addr, uptr size) { … }
SANITIZER_INTERFACE_ATTRIBUTE
void dfsan_set_label(dfsan_label label, void *addr, uptr size) { … }
SANITIZER_INTERFACE_ATTRIBUTE
void dfsan_add_label(dfsan_label label, void *addr, uptr size) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
__dfsw_dfsan_get_label(long data, dfsan_label data_label,
dfsan_label *ret_label) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_label __dfso_dfsan_get_label(
long data, dfsan_label data_label, dfsan_label *ret_label,
dfsan_origin data_origin, dfsan_origin *ret_origin) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_origin __dfsw_dfsan_get_origin(
long data, dfsan_label data_label, dfsan_label *ret_label) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_origin __dfso_dfsan_get_origin(
long data, dfsan_label data_label, dfsan_label *ret_label,
dfsan_origin data_origin, dfsan_origin *ret_origin) { … }
SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
dfsan_read_label(const void *addr, uptr size) { … }
SANITIZER_INTERFACE_ATTRIBUTE dfsan_origin
dfsan_read_origin_of_first_taint(const void *addr, uptr size) { … }
SANITIZER_INTERFACE_ATTRIBUTE void dfsan_set_label_origin(dfsan_label label,
dfsan_origin origin,
void *addr,
uptr size) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE int
dfsan_has_label(dfsan_label label, dfsan_label elem) { … }
namespace __dfsan {
dfsan_conditional_callback_t;
}
static dfsan_conditional_callback_t conditional_callback = …;
static dfsan_label labels_in_signal_conditional = …;
static void ConditionalCallback(dfsan_label label, dfsan_origin origin) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
__dfsan_conditional_callback_origin(dfsan_label label, dfsan_origin origin) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __dfsan_conditional_callback(
dfsan_label label) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void dfsan_set_conditional_callback(
__dfsan::dfsan_conditional_callback_t callback) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
dfsan_get_labels_in_signal_conditional() { … }
namespace __dfsan {
dfsan_reaches_function_callback_t;
}
static dfsan_reaches_function_callback_t reaches_function_callback = …;
static dfsan_label labels_in_signal_reaches_function = …;
static void ReachesFunctionCallback(dfsan_label label, dfsan_origin origin,
const char *file, unsigned int line,
const char *function) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
__dfsan_reaches_function_callback_origin(dfsan_label label, dfsan_origin origin,
const char *file, unsigned int line,
const char *function) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
__dfsan_reaches_function_callback(dfsan_label label, const char *file,
unsigned int line, const char *function) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
dfsan_set_reaches_function_callback(
__dfsan::dfsan_reaches_function_callback_t callback) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
dfsan_get_labels_in_signal_reaches_function() { … }
namespace {
class Decorator : public __sanitizer::SanitizerCommonDecorator { … };
}
static void PrintNoOriginTrackingWarning() { … }
static void PrintNoTaintWarning(const void *address) { … }
static void PrintInvalidOriginWarning(dfsan_label label, const void *address) { … }
static void PrintInvalidOriginIdWarning(dfsan_origin origin) { … }
static bool PrintOriginTraceFramesToStr(Origin o, InternalScopedString *out) { … }
static bool PrintOriginTraceToStr(const void *addr, const char *description,
InternalScopedString *out) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void dfsan_print_origin_trace(
const void *addr, const char *description) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE uptr
dfsan_sprint_origin_trace(const void *addr, const char *description,
char *out_buf, uptr out_buf_size) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void dfsan_print_origin_id_trace(
dfsan_origin origin) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE uptr dfsan_sprint_origin_id_trace(
dfsan_origin origin, char *out_buf, uptr out_buf_size) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_origin
dfsan_get_init_origin(const void *addr) { … }
void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
void *context,
bool request_fast,
u32 max_depth) { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_print_stack_trace() { … }
extern "C" SANITIZER_INTERFACE_ATTRIBUTE uptr
dfsan_sprint_stack_trace(char *out_buf, uptr out_buf_size) { … }
void Flags::SetDefaults() { … }
static void RegisterDfsanFlags(FlagParser *parser, Flags *f) { … }
static void InitializeFlags() { … }
SANITIZER_INTERFACE_ATTRIBUTE
void dfsan_clear_arg_tls(uptr offset, uptr size) { … }
SANITIZER_INTERFACE_ATTRIBUTE
void dfsan_clear_thread_local_state() { … }
SANITIZER_INTERFACE_ATTRIBUTE
void dfsan_set_arg_tls(uptr offset, dfsan_label label) { … }
SANITIZER_INTERFACE_ATTRIBUTE
void dfsan_set_arg_origin_tls(uptr offset, dfsan_origin o) { … }
extern "C" void dfsan_flush() { … }
static void CheckMemoryLayoutSanity() { … }
static bool CheckMemoryRangeAvailability(uptr beg, uptr size, bool verbose) { … }
static bool ProtectMemoryRange(uptr beg, uptr size, const char *name) { … }
static bool InitShadow(bool init_origins, bool dry_run) { … }
static bool InitShadowWithReExec(bool init_origins) { … }
static void DFsanInit(int argc, char **argv, char **envp) { … }
void __dfsan::dfsan_init() { … }
#if SANITIZER_CAN_USE_PREINIT_ARRAY
__attribute__((section(".preinit_array"),
used)) static void (*dfsan_init_ptr)(int, char **,
char **) = …;
#endif