Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mm/sw_tags: add config for no longer checking for tags 0 #14114

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,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
Expand Down
10 changes: 9 additions & 1 deletion mm/kasan/sw_tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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)
{
Expand Down
Loading