malloc: Add a Kconfig option for heap protection
Add CONFIG_MCHECK_HEAP_PROTECTION option to enable mcheck heap protection. Convert all uses of MCHECK_HEAP_PROTECTION to use the CONFIG_ -prefixed version to work with Kconfig. Disable this option when tracing is enabled, since the mcheck hooks (mcheck_pedantic_prehook(), etc.) interfere with function tracing. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
10
Kconfig
10
Kconfig
@@ -345,6 +345,16 @@ config MALLOC_DEBUG
|
||||
enables additional assertions and the malloc_get_info() function
|
||||
to retrieve memory-allocation statistics.
|
||||
|
||||
config MCHECK_HEAP_PROTECTION
|
||||
bool "Enable mcheck heap protection"
|
||||
depends on !TRACE
|
||||
help
|
||||
Enable heap protection using the mcheck library. This adds canary
|
||||
values before and after each allocation to detect buffer overflows
|
||||
and underflows, double-frees, and memory corruption. This
|
||||
significantly increases memory overhead and should only be used for
|
||||
debugging.
|
||||
|
||||
config SPL_SYS_MALLOC_F
|
||||
bool "Enable malloc() pool in SPL"
|
||||
depends on SPL_FRAMEWORK && SYS_MALLOC_F && SPL
|
||||
|
||||
Reference in New Issue
Block a user