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 <yinshengkai@xiaomi.com>
This commit is contained in:
yinshengkai 2024-04-22 19:43:55 +08:00 committed by Xiang Xiao
parent 13a0682340
commit 1771d233c9
1 changed files with 5 additions and 0 deletions

View File

@ -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;