mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 18:27:56 +08:00
kasan/hook.c: prevent recursive report overflow
Stop the report handler from re-entering KASAN by halting checks when printing. Reuse the dump_only flag so read/write panic toggles only emit stack traces. Retain stack dumps for panic-disabled paths without risking another overflow. Signed-off-by: anpeiyun <anpeiyun@xiaomi.com>
This commit is contained in:
+11
-2
@@ -180,6 +180,16 @@ static void kasan_report(FAR const void *addr, size_t size,
|
||||
irqstate_t flags;
|
||||
|
||||
flags = enter_critical_section();
|
||||
bool dump_only = (is_write && MM_KASAN_DISABLE_WRITE_PANIC) ||
|
||||
(!is_write && MM_KASAN_DISABLE_READ_PANIC);
|
||||
|
||||
#ifdef CONFIG_MM_KASAN
|
||||
if (!dump_only)
|
||||
{
|
||||
kasan_stop();
|
||||
}
|
||||
|
||||
#endif
|
||||
_alert("kasan detected a %s access error, address at %p,"
|
||||
"size is %zu, return address: %p\n",
|
||||
is_write ? "write" : "read",
|
||||
@@ -187,8 +197,7 @@ static void kasan_report(FAR const void *addr, size_t size,
|
||||
|
||||
kasan_show_memory(addr, size, 80);
|
||||
|
||||
if ((is_write && MM_KASAN_DISABLE_WRITE_PANIC) ||
|
||||
(!is_write && MM_KASAN_DISABLE_READ_PANIC))
|
||||
if (dump_only)
|
||||
{
|
||||
dump_stack();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user