mm: add disable kasan panic configuration

In some cases we hope to be able to find errors without affecting the running of the program

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
yinshengkai 2024-01-06 21:03:39 +08:00 committed by Xiang Xiao
parent a9afed96b9
commit 5d0ffdf44e
2 changed files with 17 additions and 0 deletions

View File

@ -301,6 +301,14 @@ config MM_KASAN_GLOBAL
KEEP ( *(. data. rel. local.. LASAN0))
}", used to extract data generated by the compiler
config MM_KASAN_DISABLE_PANIC
bool "Disable panic on kasan error"
depends on MM_KASAN
default n
---help---
This option disable panic on kasan error. It will print error info
and continue to run.
config MM_UBSAN
bool "Undefined Behavior Sanitizer"
default n

View File

@ -26,6 +26,7 @@
#include <assert.h>
#include <debug.h>
#include <execinfo.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@ -191,6 +192,9 @@ static void kasan_report(FAR const void *addr, size_t size,
FAR void *return_address)
{
static int recursion;
irqstate_t flags;
flags = enter_critical_section();
if (++recursion == 1)
{
@ -200,10 +204,15 @@ static void kasan_report(FAR const void *addr, size_t size,
addr, size, return_address);
kasan_show_memory(addr, size, 80);
#ifndef CONFIG_MM_KASAN_DISABLE_PANIC
PANIC();
#else
dump_stack();
#endif
}
--recursion;
leave_critical_section(flags);
}
static bool kasan_is_poisoned(FAR const void *addr, size_t size)