mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 07:28:38 +08:00
mm/sw_tags: add config for no longer checking for tags 0
1. When dynamically loading, the read-only data of arm64 architecture is accessed through PC offset. When opening the tag kasan, because the PC value does not have a tag, accessing the read-only data will be detected with a tag mismatch error. 2. uninitial heap use 0xff poison, initial heap use 1-254 unpoison. Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
This commit is contained in:
parent
3027be72c3
commit
a5c0dbe772
2 changed files with 15 additions and 1 deletions
|
@ -323,6 +323,12 @@ config MM_KASAN_DISABLE_WRITES_CHECK
|
|||
---help---
|
||||
This option disable kasan writes check.
|
||||
|
||||
config MM_KASAN_SKIP_ZERO_TAGS
|
||||
bool "Enable skip check zero tags"
|
||||
default LIBC_MODLIB
|
||||
---help---
|
||||
This option enables not checking for zero tags.
|
||||
|
||||
config MM_KASAN_GLOBAL
|
||||
bool "Enable global data check"
|
||||
depends on MM_KASAN_ALL
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
(FAR void *)((((uint64_t)(addr)) & ~((uint64_t)0xff << KASAN_TAG_SHIFT)) | \
|
||||
(((uint64_t)(tag)) << KASAN_TAG_SHIFT))
|
||||
|
||||
#define kasan_random_tag() (rand() % ((1 << (64 - KASAN_TAG_SHIFT)) - 1))
|
||||
#define kasan_random_tag() (1 + rand() % ((1 << (64 - KASAN_TAG_SHIFT)) - 2))
|
||||
|
||||
#define KASAN_SHADOW_SCALE (sizeof(uintptr_t))
|
||||
|
||||
|
@ -103,6 +103,14 @@ kasan_is_poisoned(FAR const void *addr, size_t size)
|
|||
uint8_t tag;
|
||||
|
||||
tag = kasan_get_tag(addr);
|
||||
|
||||
#ifdef CONFIG_MM_KASAN_SKIP_ZERO_TAGS
|
||||
if (tag == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
p = kasan_mem_to_shadow(addr, size);
|
||||
if (p == NULL)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue