|
Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
|
Macros | |
| #define | SYS_HEAP_KASAN_SHADOW_BITS(_sz) |
Shadow bits required for a heap of _sz bytes (one bit per granule). | |
| #define | SYS_HEAP_KASAN_SHADOW_BUNDLES(_sz) |
uint32_t bundle count for the shadow of a heap of _sz bytes. | |
| #define | SYS_HEAP_KASAN_ENABLE(_heap_name, _heap_sz) |
| Enable KASAN shadow tracking on a struct sys_heap. | |
| #define | K_HEAP_KASAN_ENABLE(_heap_name, _heap_sz) |
| Enable KASAN shadow tracking on a struct k_heap (K_HEAP_DEFINE). | |
Functions | |
| void | heap_kasan_report (uintptr_t addr, size_t size) |
| Report a heap KASAN violation. | |
| void | heap_kasan_register (struct sys_heap *heap, sys_bitarray_t *ba) |
| Associate a shadow bitarray with a heap for KASAN tracking. | |
| #define K_HEAP_KASAN_ENABLE | ( | _heap_name, | |
| _heap_sz ) |
#include <zephyr/sys/heap_kasan.h>
Enable KASAN shadow tracking on a struct k_heap (K_HEAP_DEFINE).
Place at file scope after the K_HEAP_DEFINE line. Allocates a static shadow buffer and registers it with the heap at PRE_KERNEL_1 priority 0, before static heap init at (PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS).
| _heap_name | k_heap variable name. |
| _heap_sz | Same size passed to K_HEAP_DEFINE (compile-time constant). |
Sample usage:
| #define SYS_HEAP_KASAN_ENABLE | ( | _heap_name, | |
| _heap_sz ) |
#include <zephyr/sys/heap_kasan.h>
Enable KASAN shadow tracking on a struct sys_heap.
Place at file scope after the sys_heap declaration. Allocates a static shadow buffer and registers it with the heap at PRE_KERNEL_1 priority 0. sys_heap_init() must be called after.
| _heap_name | sys_heap variable name. |
| _heap_sz | Heap buffer size in bytes (compile-time constant). |
Sample usage:
| #define SYS_HEAP_KASAN_SHADOW_BITS | ( | _sz | ) |
#include <zephyr/sys/heap_kasan.h>
Shadow bits required for a heap of _sz bytes (one bit per granule).
| #define SYS_HEAP_KASAN_SHADOW_BUNDLES | ( | _sz | ) |
#include <zephyr/sys/heap_kasan.h>
uint32_t bundle count for the shadow of a heap of _sz bytes.
| void heap_kasan_register | ( | struct sys_heap * | heap, |
| sys_bitarray_t * | ba ) |
#include <zephyr/sys/heap_kasan.h>
Associate a shadow bitarray with a heap for KASAN tracking.
Enables KASAN shadow tracking on a heap that was not registered at build time via SYS_HEAP_KASAN_ENABLE() or K_HEAP_KASAN_ENABLE(). Useful for dynamically created heaps.
| heap | sys_heap to track. |
| ba | Shadow bitarray; must have at least SYS_HEAP_KASAN_SHADOW_BITS(heap_size) bits backed by SYS_HEAP_KASAN_SHADOW_BUNDLES(heap_size) uint32_t bundles. |
| void heap_kasan_report | ( | uintptr_t | addr, |
| size_t | size ) |
#include <zephyr/sys/heap_kasan.h>
Report a heap KASAN violation.
Weak default calls k_panic(). Override in test code to intercept violations without triggering a panic.
| addr | Violating address. |
| size | Write size in bytes. |