mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
mm/kasan: Increase size alignment
The following situations cannot be detected by Kasan: On a 32-bit machine, only 12 bytes were poisoned, but 13 bytes were accessed. Due to the lack of upward alignment, only 3 bits were detected Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
This commit is contained in:
committed by
Xiang Xiao
parent
b7d5a30f85
commit
4473f2f847
@@ -24,6 +24,7 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/nuttx.h>
|
||||||
#include <nuttx/mm/kasan.h>
|
#include <nuttx/mm/kasan.h>
|
||||||
#include <nuttx/spinlock.h>
|
#include <nuttx/spinlock.h>
|
||||||
|
|
||||||
@@ -210,6 +211,7 @@ bool kasan_is_poisoned(FAR const void *addr, size_t size)
|
|||||||
|
|
||||||
nbit = KASAN_BITS_PER_WORD - bit % KASAN_BITS_PER_WORD;
|
nbit = KASAN_BITS_PER_WORD - bit % KASAN_BITS_PER_WORD;
|
||||||
mask = KASAN_FIRST_WORD_MASK(bit);
|
mask = KASAN_FIRST_WORD_MASK(bit);
|
||||||
|
size = ALIGN_UP(size, KASAN_SHADOW_SCALE);
|
||||||
size /= KASAN_SHADOW_SCALE;
|
size /= KASAN_SHADOW_SCALE;
|
||||||
|
|
||||||
while (size >= nbit)
|
while (size >= nbit)
|
||||||
|
|||||||
Reference in New Issue
Block a user