From e26e1ab2ab6ea073728d3fafd1999f81ea397676 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Tue, 16 Jan 2024 16:47:04 +0800 Subject: [PATCH] kasan:fix bug if kasan_mem_to_shadow mod size is 0 just return Signed-off-by: anjiahao --- mm/kasan/kasan.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c index cab1ada376..abe51009c6 100644 --- a/mm/kasan/kasan.c +++ b/mm/kasan/kasan.c @@ -149,7 +149,7 @@ static FAR uintptr_t *kasan_mem_to_shadow(FAR const void *ptr, size_t size, size_t mod; size_t i; - if (g_region_init != KASAN_INIT_VALUE || size == 0) + if (g_region_init != KASAN_INIT_VALUE) { return NULL; } @@ -168,6 +168,11 @@ static FAR uintptr_t *kasan_mem_to_shadow(FAR const void *ptr, size_t size, } mod = size % KASAN_SHADOW_SCALE; + if (mod == 0) + { + return NULL; + } + addr += mul * KASAN_SHADOW_SCALE; size = mod; }