From e154c6d071c3098d7b3ac38b4164415a101d5bed Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Tue, 20 Aug 2024 16:03:14 +0800 Subject: [PATCH] mm/kasan: add null pointer access configuration Signed-off-by: yinshengkai --- mm/Kconfig | 6 ++++++ mm/kasan/hook.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/mm/Kconfig b/mm/Kconfig index 591be2ae8e..d6c00e5fe5 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -288,6 +288,12 @@ config MM_KASAN_ALL to check. Enabling this option will get image size increased and performance decreased significantly. +config MM_KASAN_DISABLE_NULL_POINTER_CHECK + bool "Disable null pointer access check" + default n + ---help--- + This option enables KASan check null pointer access. + config MM_KASAN_DISABLE_READS_CHECK bool "Disable reads check" depends on MM_KASAN diff --git a/mm/kasan/hook.c b/mm/kasan/hook.c index 946257283d..da2bd65bca 100644 --- a/mm/kasan/hook.c +++ b/mm/kasan/hook.c @@ -173,10 +173,12 @@ static inline void kasan_check_report(FAR const void *addr, size_t size, return; } +#ifndef CONFIG_MM_KASAN_DISABLE_NULL_POINTER_CHECK if (addr == NULL) { kasan_report(addr, size, is_write, return_address); } +#endif if (kasan_is_poisoned(addr, size)) {