From 1771d233c9ef1af9734d9806ea71d0e0649c9480 Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Mon, 22 Apr 2024 19:43:55 +0800 Subject: [PATCH] mm/kasan: fix kasan_is_poisoned check error When size is less than or equal to KASAN_SHADOW_SCALE, no check will be performed We need to check whether the memory is accessible based on bit Signed-off-by: yinshengkai --- mm/kasan/generic.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c index 6ea06fcc0d..513279fae1 100644 --- a/mm/kasan/generic.c +++ b/mm/kasan/generic.c @@ -211,6 +211,11 @@ bool kasan_is_poisoned(FAR const void *addr, size_t size) return false; } + if (size <= KASAN_SHADOW_SCALE) + { + return ((*p >> bit) & 1); + } + nbit = KASAN_BITS_PER_WORD - bit % KASAN_BITS_PER_WORD; mask = KASAN_FIRST_WORD_MASK(bit); size /= KASAN_SHADOW_SCALE;