13using namespace MaxOS::runtime;
15KASanHandler::KASanHandler() =
default;
17KASanHandler::~KASanHandler() =
default;
28 ASSERT(
false,
"KASAN ERROR: %s of size %zu at address 0x%lx from RIP 0x%p", write ?
"WRITE" :
"READ", size, address, rip);
172 ASSERT(
false,
"KASAN ERROR: Function marked 'noreturn' has returned");
183 ASSERT(
false,
"KASAN ERROR: Stack poisoning not implemented for address 0x%lx of size %zu", address, size);
194 ASSERT(
false,
"KASAN ERROR: Stack unpoisoning not implemented for range 0x%p - 0x%p", stack_bottom, stack_top);
206 for(
int i = 0; i < size; ++i)
207 ((int8_t*)pointer)[i] = 0;
220 for(
int i = 0; i < size; ++i)
221 ((int8_t*)pointer)[i] = 0xF8;
static void unpoison_stack(uintptr_t address, size_t size)
Marks a region of stack memory as unpoisoned (accessible)
static void handle(bool write, uintptr_t address, size_t size, void *rip)
Handles a KASan error by panicking and printing the details.
static void poison_stack(uintptr_t address, size_t size)
Marks a region of stack memory as poisoned (inaccessible)
static void initialize()
Initializes the KASan handler by setting up the shadow memory.
void __asan_load4_noabort(uintptr_t address)
Triggered when a memory load access violation of 4 bytes is detected.
void __asan_load16_noabort(uintptr_t address)
Triggered when a memory load access violation of 16 bytes is detected.
void __asan_store4_noabort(uintptr_t address)
Triggered when a memory store access violation of 4 bytes is detected.
void __asan_handle_no_return()
Triggered when a function that is expected to not return does return.
void __asan_set_shadow_00(void *pointer, size_t size)
Unpoisons a region of memory, marking it as accessible.
void __asan_alloca_unpoison(void *stack_top, void *stack_bottom)
Unpoisons a region of stack memory allocated with alloca.
void __asan_load2_noabort(uintptr_t address)
Triggered when a memory load access violation of 2 bytes is detected.
void __asan_loadN_noabort(uintptr_t address, size_t size)
Triggered when a memory load access violation of arbitrary size is detected.
void __asan_set_shadow_f8(void *pointer, size_t size)
Poisons a region of memory, marking it as inaccessible.
void __asan_load8_noabort(uintptr_t address)
Triggered when a memory load access violation of 8 bytes is detected.
void __asan_after_dynamic_init(const void *module_name)
Called after dynamic initialization of a module.
void __asan_alloca_poison(uintptr_t address, size_t size)
Poisons a region of stack memory allocated with alloca.
void __asan_storeN_noabort(uintptr_t address, size_t size)
Triggered when a memory store access violation of arbitrary size is detected.
void __asan_store2_noabort(uintptr_t address)
Triggered when a memory store access violation of 2 bytes is detected.
void __asan_store8_noabort(uintptr_t address)
Triggered when a memory store access violation of 8 bytes is detected.
void __asan_before_dynamic_init(const void *module_name)
Called before dynamic initialization of a module.
void __asan_store16_noabort(uintptr_t address)
Triggered when a memory store access violation of 16 bytes is detected.
void __asan_load1_noabort(uintptr_t address)
Triggered when a memory load access violation of 1 byte is detected.
void __asan_store1_noabort(uintptr_t address)
Triggered when a memory store access violation of 1 byte is detected.
Defines structures and a handler for Kernel Address Sanitizer (KASan) runtime errors.
Defines a Logger class for logging messages with different severity levels to multiple output streams...
#define ASSERT(condition, format,...)
If the specified condition is not met then the kernel will crash with the specified message.