Address sanitization
include/mem/asan.h View source View on GitHubFunctions
Section titled “Functions”asan_shadow_is_poison
Section titled “asan_shadow_is_poison”bool asan_shadow_is_poison(uint8_t s) source asan_init
Section titled “asan_init”void asan_init(void) source asan_shadow_install
Section titled “asan_shadow_install”Shadow backing at the slab chunk granularity, which must happen before any object in the chunk is handed off
asan_shadow_release
Section titled “asan_shadow_release”asan_alloc
Section titled “asan_alloc”void asan_alloc(void *addr, size_t requested, size_t slot) source asan_free
Section titled “asan_free”void asan_free(void *addr, size_t slot) source asan_poison
Section titled “asan_poison”void asan_poison(void *addr, size_t size) source asan_unpoison
Section titled “asan_unpoison”void asan_unpoison(void *addr, size_t size) source asan_init
Section titled “asan_init”void asan_init(void) source asan_shadow_install
Section titled “asan_shadow_install”asan_shadow_release
Section titled “asan_shadow_release”asan_alloc
Section titled “asan_alloc”void asan_alloc(void *addr, size_t requested, size_t slot) source asan_free
Section titled “asan_free”void asan_free(void *addr, size_t slot) source asan_poison
Section titled “asan_poison”void asan_poison(void *addr, size_t size) source asan_unpoison
Section titled “asan_unpoison”void asan_unpoison(void *addr, size_t size) source Variables
Section titled “Variables”__log_site_asan
Section titled “__log_site_asan” LOG_SITE_EXTERN(asan) (1 declaration) source
__log_handle_asan
Section titled “__log_handle_asan” LOG_HANDLE_EXTERN(asan) (1 declaration) source
§
struct log_handle __log_handle_asan Macros
Section titled “Macros”ASAN_SHADOW_SCALE
Section titled “ASAN_SHADOW_SCALE”#define ASAN_SHADOW_SCALE 3ULL source 1 shadow byte per 8 real bytes
ASAN_SHADOW_OFFSET
Section titled “ASAN_SHADOW_OFFSET”#define ASAN_SHADOW_OFFSET 0xDFFFFE0000000000 source ASAN_SHADOW_ADDR
Section titled “ASAN_SHADOW_ADDR”#define ASAN_SHADOW_ADDR(a) source offset = SHADOW_REGION_START - (COVERED_START >> SHADOW_SCALE) shadow = (addr >> scale) + offset
Expansion
#define ASAN_SHADOW_ADDR(a) \
((uintptr_t) (((uintptr_t) (a) >> ASAN_SHADOW_SCALE) + ASAN_SHADOW_OFFSET)) ASAN_GRANULE
Section titled “ASAN_GRANULE”#define ASAN_GRANULE ((uintptr_t) BIT(ASAN_SHADOW_SCALE)) source ASAN_REDZONE
Section titled “ASAN_REDZONE”#define ASAN_REDZONE 16 source optional redzone per allocation
ASAN_POISON_VALUE
Section titled “ASAN_POISON_VALUE”#define ASAN_POISON_VALUE 0xFF source Shadow byte encoding, one per ASAN_GRANULE bytes of memory:
0 - whole granule accessible 1..7 first k bytes accessible >= 0x80 nothing in granule accessible
generic: never handed out
ASAN_POISON_HEAP_REDZONE
Section titled “ASAN_POISON_HEAP_REDZONE”#define ASAN_POISON_HEAP_REDZONE 0xFA source slack around/inside a live slot
ASAN_POISON_HEAP_FREED
Section titled “ASAN_POISON_HEAP_FREED”#define ASAN_POISON_HEAP_FREED 0xFD source was live, has been freed
ASAN_ABORT_IF_NOT_READY
Section titled “ASAN_ABORT_IF_NOT_READY”#define ASAN_ABORT_IF_NOT_READY() source Expansion
#define ASAN_ABORT_IF_NOT_READY() \
do { \
if (!asan_ready) \
return; \
} while (0) asan_log
Section titled “asan_log”#define asan_log(lvl, fmt, ...) source Expansion
#define asan_log(lvl, fmt, ...) \
log(LOG_SITE(asan), LOG_HANDLE(asan), lvl, fmt, ##__VA_ARGS__) asan_err
Section titled “asan_err”#define asan_err(fmt, ...) source asan_warn
Section titled “asan_warn”#define asan_warn(fmt, ...) source asan_info
Section titled “asan_info”#define asan_info(fmt, ...) source asan_debug
Section titled “asan_debug”#define asan_debug(fmt, ...) source Expansion
#define asan_debug(fmt, ...) asan_log(LOG_DEBUG, fmt, ##__VA_ARGS__) asan_trace
Section titled “asan_trace”#define asan_trace(fmt, ...) source Expansion
#define asan_trace(fmt, ...) asan_log(LOG_TRACE, fmt, ##__VA_ARGS__)