Expand description
ABI for interfacing with KASAN shadow memory
KASAN functions by keeping an in-memory shadow map of all kernelspace memory. Each byte in the shadow map represents 8 bytes of kernel memory, which can either be accessible, partially accessible, or poisoned.
There are a range of poison values used in Popcorn2, some of which are defined by compiler ABI. In practice not all of these values are used. The current list is:
0xfa: Heap left redzone - memory just before a heap allocation0xfb: Heap right redzone - memory just after a heap allocation0xfc: Heap headers - memory used by heap internals0xfd: Freed heap memory - heap memory that has recently been deallocated, and is currently in a quarantine period0xf1: Stack left redzone - memory just before a stack allocation0xf2: Stack mid redzone - memory between two stack allocations0xf3: Stack right redzone - memory just after a stack allocation0xf4: Stack guard page - the page of unmapped memory below the stack to catch stack overflows0xf5: Stack after return - the stack frame of a function that has already returned, used to catch dangling references returned by a function0xf8: Stack use after scope - a stack slot in the current function but is now out of scope0xf9: Global redzone - memory around global variables0xc0: Freed virtual memory - memory that has just been deallocated by aVmm0xc1: Uninitialized virtual memory - memory that has never been allocated0xcc: Shadow gap - the shadow map itself
Re-exports§
pub use super::*;
Modules§
- full 🔒
full
Macros§
- no_
asan_ shim full
Constants§
- SHADOW_
MAP_ END - Address of the end of the shadow map region.
- SHADOW_
MAP_ SHIFT - Offset to add to
addr / 8to calculate shadow map address. - SHADOW_
MAP_ 🔒SIZE - SHADOW_
MAP_ START - Address of the start of the shadow map region.
Functions§
- asan_
free_ range full - Marks the region from
starttostart + countas accessible - count_
to_ shadow - Converts the number of bytes into the lower bound number of bytes in the shadow map.
- mem_
to_ shadow - Converts the passed
addressinto the corresponding address in the shadow map. - read_
shadow_ map_ for full - read_
shadow_ map_ raw full - set_
shadow_ ⚠free full - Marks
countentries in the shadow map starting ataddressas “accessible” - set_
shadow_ ⚠free_ vmem full - Marks
countentries in the shadow map starting ataddressas “freed virtual memory” - set_
shadow_ ⚠heap_ free full - Marks
countentries in the shadow map starting ataddressas “freed heap memory” - set_
shadow_ ⚠heap_ header full - Marks
countentries in the shadow map starting ataddressas “heap headers”. - set_
shadow_ ⚠heap_ left full - Marks
countentries in the shadow map starting ataddressas “heap left redzone” - set_
shadow_ ⚠heap_ right full - Marks
countentries in the shadow map starting ataddressas “heap right redzone”. - set_
shadow_ ⚠stack_ left full - Marks
countentries in the shadow map starting ataddressas “stack left redzone” - set_
shadow_ ⚠uninit_ vmem full - Marks
countentries in the shadow map starting ataddressas “uninitialized virtual memory” - set_
shadow_ ⚠use_ after_ scope full - Marks
countentries in the shadow map starting ataddressas “stack use after scope” - write_
shadow_ map_ for full - write_
shadow_ map_ raw full - If
idxis greater thanSHADOW_MAP_END - SHADOW_MAP_START.