mm/kasan: support Disable Kasan read Panic
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
parent
d365be9f2f
commit
be86b03794
15
mm/Kconfig
15
mm/Kconfig
|
@ -320,14 +320,23 @@ 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"
|
||||
config MM_KASAN_DISABLE_READ_PANIC
|
||||
bool "Disable panic on kasan read error"
|
||||
default n
|
||||
---help---
|
||||
This option disable panic on kasan read error. It will print error info
|
||||
and continue to run.
|
||||
|
||||
config MM_KASAN_DISABLE_WRITE_PANIC
|
||||
bool "Disable panic on kasan write error"
|
||||
depends on MM_KASAN
|
||||
default n
|
||||
---help---
|
||||
This option disable panic on kasan error. It will print error info
|
||||
This option disable panic on kasan write error. It will print error info
|
||||
and continue to run.
|
||||
|
||||
endif # MM_KASAN
|
||||
|
||||
config MM_UBSAN
|
||||
bool "Undefined Behavior Sanitizer"
|
||||
default n
|
||||
|
|
|
@ -71,6 +71,18 @@
|
|||
kasan_check_report(addr, size, true, return_address(0)); \
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MM_KASAN_DISABLE_READ_PANIC
|
||||
# define MM_KASAN_DISABLE_READ_PANIC 1
|
||||
#else
|
||||
# define MM_KASAN_DISABLE_READ_PANIC 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MM_KASAN_DISABLE_WRITE_PANIC
|
||||
# define MM_KASAN_DISABLE_WRITE_PANIC 1
|
||||
#else
|
||||
# define MM_KASAN_DISABLE_WRITE_PANIC 0
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -130,11 +142,16 @@ 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
|
||||
|
||||
if ((is_write && MM_KASAN_DISABLE_WRITE_PANIC) ||
|
||||
(!is_write && MM_KASAN_DISABLE_READ_PANIC))
|
||||
{
|
||||
dump_stack();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
PANIC();
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue