mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
kasan/kconfig: Add config CONFIG_MM_KASAN_INSTRUMENT
Build Documentation / build-html (push) Has been cancelled
Build Documentation / build-html (push) Has been cancelled
It will be used to distinguish between hardware KASan and software KASan. Hardware KASan does not need to use plug-in Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
This commit is contained in:
committed by
Xiang Xiao
parent
9b4cd4e0a4
commit
df7d062713
@@ -41,7 +41,7 @@ Usage
|
|||||||
To enable Generic KASAN, configure the kernel with::
|
To enable Generic KASAN, configure the kernel with::
|
||||||
|
|
||||||
CONFIG_MM_KASAN=y
|
CONFIG_MM_KASAN=y
|
||||||
CONFIG_MM_KASAN_ALL=y
|
CONFIG_MM_KASAN_INSTRUMENT_ALL=y
|
||||||
CONFIG_MM_KASAN_GENERIC=y
|
CONFIG_MM_KASAN_GENERIC=y
|
||||||
|
|
||||||
If you want to enable global variable out of bounds detection,
|
If you want to enable global variable out of bounds detection,
|
||||||
@@ -52,7 +52,7 @@ you can add configurations based on the above::
|
|||||||
To enable Software Tag-Based KASAN, configure the kernel with::
|
To enable Software Tag-Based KASAN, configure the kernel with::
|
||||||
|
|
||||||
CONFIG_MM_KASAN=y
|
CONFIG_MM_KASAN=y
|
||||||
CONFIG_MM_KASAN_ALL=y
|
CONFIG_MM_KASAN_INSTRUMENT_ALL=y
|
||||||
CONFIG_MM_KASAN_SW_TAGS=y
|
CONFIG_MM_KASAN_SW_TAGS=y
|
||||||
|
|
||||||
Implementation details
|
Implementation details
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ if(CONFIG_MM_UBSAN_TRAP_ON_ERROR)
|
|||||||
add_compile_options(-fsanitize-undefined-trap-on-error)
|
add_compile_options(-fsanitize-undefined-trap-on-error)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_MM_KASAN_ALL)
|
if(CONFIG_MM_KASAN_INSTRUMENT_ALL)
|
||||||
add_compile_options(-fsanitize=kernel-address)
|
add_compile_options(-fsanitize=kernel-address)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ if(CONFIG_MM_UBSAN_TRAP_ON_ERROR)
|
|||||||
add_compile_options(-fsanitize-undefined-trap-on-error)
|
add_compile_options(-fsanitize-undefined-trap-on-error)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_MM_KASAN_ALL)
|
if(CONFIG_MM_KASAN_INSTRUMENT_ALL)
|
||||||
add_compile_options(-fsanitize=kernel-address)
|
add_compile_options(-fsanitize=kernel-address)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ if(CONFIG_MM_UBSAN_TRAP_ON_ERROR)
|
|||||||
add_compile_options(-fsanitize-undefined-trap-on-error)
|
add_compile_options(-fsanitize-undefined-trap-on-error)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_MM_KASAN_ALL)
|
if(CONFIG_MM_KASAN_INSTRUMENT_ALL)
|
||||||
add_compile_options(-fsanitize=kernel-address)
|
add_compile_options(-fsanitize=kernel-address)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ if(CONFIG_MM_UBSAN_TRAP_ON_ERROR)
|
|||||||
add_compile_options(-fsanitize-undefined-trap-on-error)
|
add_compile_options(-fsanitize-undefined-trap-on-error)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_MM_KASAN_ALL)
|
if(CONFIG_MM_KASAN_INSTRUMENT_ALL)
|
||||||
add_compile_options(-fsanitize=kernel-address)
|
add_compile_options(-fsanitize=kernel-address)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
|
|||||||
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
|
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_MM_KASAN_ALL),y)
|
ifeq ($(CONFIG_MM_KASAN_INSTRUMENT_ALL),y)
|
||||||
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
|
|||||||
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
|
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_MM_KASAN_ALL),y)
|
ifeq ($(CONFIG_MM_KASAN_INSTRUMENT_ALL),y)
|
||||||
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ if(CONFIG_MM_UBSAN_TRAP_ON_ERROR)
|
|||||||
add_compile_options(-fsanitize-undefined-trap-on-error)
|
add_compile_options(-fsanitize-undefined-trap-on-error)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_MM_KASAN_ALL)
|
if(CONFIG_MM_KASAN_INSTRUMENT_ALL)
|
||||||
add_compile_options(-fsanitize=kernel-address)
|
add_compile_options(-fsanitize=kernel-address)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -365,7 +365,7 @@ if(CONFIG_RISCV_TOOLCHAIN STREQUAL GNU_RVG)
|
|||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_MM_KASAN_ALL)
|
if(CONFIG_MM_KASAN_INSTRUMENT_ALL)
|
||||||
add_compile_options(-fsanitize=kernel-address)
|
add_compile_options(-fsanitize=kernel-address)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_MM_KASAN_ALL),y)
|
ifeq ($(CONFIG_MM_KASAN_INSTRUMENT_ALL),y)
|
||||||
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ if(CONFIG_SIM_ASAN)
|
|||||||
add_compile_options(-fsanitize=pointer-compare)
|
add_compile_options(-fsanitize=pointer-compare)
|
||||||
add_compile_options(-fsanitize=pointer-subtract)
|
add_compile_options(-fsanitize=pointer-subtract)
|
||||||
add_link_options(-fsanitize=address)
|
add_link_options(-fsanitize=address)
|
||||||
elseif(CONFIG_MM_KASAN_ALL)
|
elseif(CONFIG_MM_KASAN_INSTRUMENT_ALL)
|
||||||
add_compile_options(-fsanitize=kernel-address)
|
add_compile_options(-fsanitize=kernel-address)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
|
|||||||
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
|
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_MM_KASAN_ALL),y)
|
ifeq ($(CONFIG_MM_KASAN_INSTRUMENT_ALL),y)
|
||||||
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ NM = $(CROSSDEV)nm
|
|||||||
OBJCOPY = $(CROSSDEV)objcopy
|
OBJCOPY = $(CROSSDEV)objcopy
|
||||||
OBJDUMP = $(CROSSDEV)objdump
|
OBJDUMP = $(CROSSDEV)objdump
|
||||||
|
|
||||||
ifeq ($(CONFIG_MM_KASAN_ALL),y)
|
ifeq ($(CONFIG_MM_KASAN_INSTRUMENT_ALL),y)
|
||||||
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ ifeq ($(CONFIG_LIBCXX),y)
|
|||||||
CXXFLAGS += -D_LIBCPP_DISABLE_AVAILABILITY
|
CXXFLAGS += -D_LIBCPP_DISABLE_AVAILABILITY
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_MM_KASAN_ALL),y)
|
ifeq ($(CONFIG_MM_KASAN_INSTRUMENT_ALL),y)
|
||||||
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
||||||
endif
|
endif
|
||||||
ifeq ($(CONFIG_MM_KASAN_GLOBAL),y)
|
ifeq ($(CONFIG_MM_KASAN_GLOBAL),y)
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ add_compile_options(-mlongcalls)
|
|||||||
|
|
||||||
add_compile_options(-mtext-section-literals)
|
add_compile_options(-mtext-section-literals)
|
||||||
|
|
||||||
if(CONFIG_MM_KASAN_ALL)
|
if(CONFIG_MM_KASAN_INSTRUMENT_ALL)
|
||||||
add_compile_options(-fsanitize=kernel-address)
|
add_compile_options(-fsanitize=kernel-address)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ endif
|
|||||||
|
|
||||||
ARCHCPUFLAGS = -mlongcalls
|
ARCHCPUFLAGS = -mlongcalls
|
||||||
|
|
||||||
ifeq ($(CONFIG_MM_KASAN_ALL),y)
|
ifeq ($(CONFIG_MM_KASAN_INSTRUMENT_ALL),y)
|
||||||
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ endif
|
|||||||
|
|
||||||
ARCHCPUFLAGS = -mlongcalls
|
ARCHCPUFLAGS = -mlongcalls
|
||||||
|
|
||||||
ifeq ($(CONFIG_MM_KASAN_ALL),y)
|
ifeq ($(CONFIG_MM_KASAN_INSTRUMENT_ALL),y)
|
||||||
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ endif
|
|||||||
ifeq ($(CONFIG_SIM_ASAN),y)
|
ifeq ($(CONFIG_SIM_ASAN),y)
|
||||||
ARCHOPTIMIZATION += -fsanitize=address -fsanitize-address-use-after-scope
|
ARCHOPTIMIZATION += -fsanitize=address -fsanitize-address-use-after-scope
|
||||||
ARCHOPTIMIZATION += -fsanitize=pointer-compare -fsanitize=pointer-subtract
|
ARCHOPTIMIZATION += -fsanitize=pointer-compare -fsanitize=pointer-subtract
|
||||||
else ifeq ($(CONFIG_MM_KASAN_ALL),y)
|
else ifeq ($(CONFIG_MM_KASAN_INSTRUMENT_ALL),y)
|
||||||
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
ARCHOPTIMIZATION += -fsanitize=kernel-address
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ size_t ARCH_LIBCFUN(strnlen)(FAR const char *s, size_t maxlen);
|
|||||||
FAR char *ARCH_LIBCFUN(strrchr)(FAR const char *s, int c);
|
FAR char *ARCH_LIBCFUN(strrchr)(FAR const char *s, int c);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
||||||
extern void __asan_loadN(FAR void *addr, size_t size);
|
extern void __asan_loadN(FAR void *addr, size_t size);
|
||||||
# endif
|
# endif
|
||||||
@@ -106,7 +106,7 @@ extern void __asan_storeN(FAR void *addr, size_t size);
|
|||||||
|
|
||||||
FAR void *memchr(FAR const void *s, int c, size_t n)
|
FAR void *memchr(FAR const void *s, int c, size_t n)
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
||||||
__asan_loadN((FAR void *)s, n);
|
__asan_loadN((FAR void *)s, n);
|
||||||
# endif
|
# endif
|
||||||
@@ -119,7 +119,7 @@ FAR void *memchr(FAR const void *s, int c, size_t n)
|
|||||||
#ifdef CONFIG_LIBC_ARCH_MEMCPY
|
#ifdef CONFIG_LIBC_ARCH_MEMCPY
|
||||||
FAR void *memcpy(FAR void *dest, FAR const void *src, FAR size_t n)
|
FAR void *memcpy(FAR void *dest, FAR const void *src, FAR size_t n)
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_WRITES_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_WRITES_CHECK
|
||||||
__asan_storeN(dest, n);
|
__asan_storeN(dest, n);
|
||||||
# endif
|
# endif
|
||||||
@@ -134,7 +134,7 @@ FAR void *memcpy(FAR void *dest, FAR const void *src, FAR size_t n)
|
|||||||
#ifdef CONFIG_LIBC_ARCH_MEMCMP
|
#ifdef CONFIG_LIBC_ARCH_MEMCMP
|
||||||
int memcmp(FAR const void *s1, FAR const void *s2, size_t n)
|
int memcmp(FAR const void *s1, FAR const void *s2, size_t n)
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
||||||
__asan_loadN((FAR void *)s1, n);
|
__asan_loadN((FAR void *)s1, n);
|
||||||
__asan_loadN((FAR void *)s2, n);
|
__asan_loadN((FAR void *)s2, n);
|
||||||
@@ -147,7 +147,7 @@ int memcmp(FAR const void *s1, FAR const void *s2, size_t n)
|
|||||||
#ifdef CONFIG_LIBC_ARCH_MEMMOVE
|
#ifdef CONFIG_LIBC_ARCH_MEMMOVE
|
||||||
FAR void *memmove(FAR void *dest, FAR const void *src, FAR size_t n)
|
FAR void *memmove(FAR void *dest, FAR const void *src, FAR size_t n)
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_WRITES_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_WRITES_CHECK
|
||||||
__asan_storeN(dest, n);
|
__asan_storeN(dest, n);
|
||||||
# endif
|
# endif
|
||||||
@@ -162,7 +162,7 @@ FAR void *memmove(FAR void *dest, FAR const void *src, FAR size_t n)
|
|||||||
#ifdef CONFIG_LIBC_ARCH_MEMSET
|
#ifdef CONFIG_LIBC_ARCH_MEMSET
|
||||||
FAR void *memset(FAR void *s, int c, FAR size_t n)
|
FAR void *memset(FAR void *s, int c, FAR size_t n)
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_WRITES_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_WRITES_CHECK
|
||||||
__asan_storeN(s, n);
|
__asan_storeN(s, n);
|
||||||
# endif
|
# endif
|
||||||
@@ -174,7 +174,7 @@ FAR void *memset(FAR void *s, int c, FAR size_t n)
|
|||||||
#ifdef CONFIG_LIBC_ARCH_STRCMP
|
#ifdef CONFIG_LIBC_ARCH_STRCMP
|
||||||
int strcmp(FAR const char *s1, FAR const char *s2)
|
int strcmp(FAR const char *s1, FAR const char *s2)
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
||||||
__asan_loadN((FAR void *)s1, ARCH_LIBCFUN(strlen)(s1) + 1);
|
__asan_loadN((FAR void *)s1, ARCH_LIBCFUN(strlen)(s1) + 1);
|
||||||
__asan_loadN((FAR void *)s2, ARCH_LIBCFUN(strlen)(s2) + 1);
|
__asan_loadN((FAR void *)s2, ARCH_LIBCFUN(strlen)(s2) + 1);
|
||||||
@@ -187,7 +187,7 @@ int strcmp(FAR const char *s1, FAR const char *s2)
|
|||||||
#ifdef CONFIG_LIBC_ARCH_STRCPY
|
#ifdef CONFIG_LIBC_ARCH_STRCPY
|
||||||
FAR char *strcpy(FAR char *dest, FAR const char *src)
|
FAR char *strcpy(FAR char *dest, FAR const char *src)
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_WRITES_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_WRITES_CHECK
|
||||||
__asan_storeN(dest, ARCH_LIBCFUN(strlen)(src) + 1);
|
__asan_storeN(dest, ARCH_LIBCFUN(strlen)(src) + 1);
|
||||||
# endif
|
# endif
|
||||||
@@ -203,7 +203,7 @@ FAR char *strcpy(FAR char *dest, FAR const char *src)
|
|||||||
size_t strlen(FAR const char *s)
|
size_t strlen(FAR const char *s)
|
||||||
{
|
{
|
||||||
size_t ret = ARCH_LIBCFUN(strlen)(s);
|
size_t ret = ARCH_LIBCFUN(strlen)(s);
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
||||||
__asan_loadN((FAR void *)s, ret + 1);
|
__asan_loadN((FAR void *)s, ret + 1);
|
||||||
# endif
|
# endif
|
||||||
@@ -215,7 +215,7 @@ size_t strlen(FAR const char *s)
|
|||||||
#ifdef CONFIG_LIBC_ARCH_STRNCPY
|
#ifdef CONFIG_LIBC_ARCH_STRNCPY
|
||||||
FAR char *strncpy(FAR char *dest, FAR const char *src, size_t n)
|
FAR char *strncpy(FAR char *dest, FAR const char *src, size_t n)
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_WRITES_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_WRITES_CHECK
|
||||||
__asan_storeN(dest, n);
|
__asan_storeN(dest, n);
|
||||||
# endif
|
# endif
|
||||||
@@ -230,7 +230,7 @@ FAR char *strncpy(FAR char *dest, FAR const char *src, size_t n)
|
|||||||
#ifdef CONFIG_LIBC_ARCH_STRCHR
|
#ifdef CONFIG_LIBC_ARCH_STRCHR
|
||||||
FAR char *strchr(FAR const char *s, int c)
|
FAR char *strchr(FAR const char *s, int c)
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
||||||
__asan_loadN((FAR void *)s, ARCH_LIBCFUN(strlen)(s) + 1);
|
__asan_loadN((FAR void *)s, ARCH_LIBCFUN(strlen)(s) + 1);
|
||||||
# endif
|
# endif
|
||||||
@@ -243,7 +243,7 @@ FAR char *strchr(FAR const char *s, int c)
|
|||||||
#ifdef CONFIG_LIBC_ARCH_STRCHNUL
|
#ifdef CONFIG_LIBC_ARCH_STRCHNUL
|
||||||
FAR char *strchrnul(FAR const char *s, int c);
|
FAR char *strchrnul(FAR const char *s, int c);
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
||||||
__asan_loadN((FAR void *)s, ARCH_LIBCFUN(strlen)(s) + 1);
|
__asan_loadN((FAR void *)s, ARCH_LIBCFUN(strlen)(s) + 1);
|
||||||
# endif
|
# endif
|
||||||
@@ -255,7 +255,7 @@ FAR char *strchrnul(FAR const char *s, int c);
|
|||||||
#ifdef CONFIG_LIBC_ARCH_STRNCMP
|
#ifdef CONFIG_LIBC_ARCH_STRNCMP
|
||||||
int strncmp(FAR const char *s1, FAR const char *s2, size_t n)
|
int strncmp(FAR const char *s1, FAR const char *s2, size_t n)
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
||||||
size_t size_s1 = ARCH_LIBCFUN(strnlen)(s1, n);
|
size_t size_s1 = ARCH_LIBCFUN(strnlen)(s1, n);
|
||||||
size_t size_s2 = ARCH_LIBCFUN(strnlen)(s2, n);
|
size_t size_s2 = ARCH_LIBCFUN(strnlen)(s2, n);
|
||||||
@@ -274,7 +274,7 @@ int strncmp(FAR const char *s1, FAR const char *s2, size_t n)
|
|||||||
size_t strnlen(FAR const char *s, size_t maxlen)
|
size_t strnlen(FAR const char *s, size_t maxlen)
|
||||||
{
|
{
|
||||||
size_t ret = ARCH_LIBCFUN(strnlen)(s, maxlen);
|
size_t ret = ARCH_LIBCFUN(strnlen)(s, maxlen);
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
||||||
__asan_loadN((FAR void *)s, ret);
|
__asan_loadN((FAR void *)s, ret);
|
||||||
# endif
|
# endif
|
||||||
@@ -287,7 +287,7 @@ size_t strnlen(FAR const char *s, size_t maxlen)
|
|||||||
#ifdef CONFIG_LIBC_ARCH_STRRCHR
|
#ifdef CONFIG_LIBC_ARCH_STRRCHR
|
||||||
FAR char *strrchr(FAR const char *s, int c)
|
FAR char *strrchr(FAR const char *s, int c)
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_MM_KASAN
|
# ifdef CONFIG_MM_KASAN_INSTRUMENT
|
||||||
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
|
||||||
__asan_loadN((FAR void *)s, ARCH_LIBCFUN(strlen)(s) + 1);
|
__asan_loadN((FAR void *)s, ARCH_LIBCFUN(strlen)(s) + 1);
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
+8
-2
@@ -11,6 +11,9 @@ config MM_KASAN
|
|||||||
bugs in native code. After turn on this option, Please
|
bugs in native code. After turn on this option, Please
|
||||||
add -fsanitize=kernel-address to CFLAGS/CXXFLAGS too.
|
add -fsanitize=kernel-address to CFLAGS/CXXFLAGS too.
|
||||||
|
|
||||||
|
config MM_KASAN_INSTRUMENT
|
||||||
|
bool
|
||||||
|
|
||||||
if MM_KASAN
|
if MM_KASAN
|
||||||
|
|
||||||
choice
|
choice
|
||||||
@@ -24,20 +27,23 @@ config MM_KASAN_NONE
|
|||||||
|
|
||||||
config MM_KASAN_GENERIC
|
config MM_KASAN_GENERIC
|
||||||
bool "KAsan generic mode"
|
bool "KAsan generic mode"
|
||||||
|
select MM_KASAN_INSTRUMENT
|
||||||
---help---
|
---help---
|
||||||
KASan generic mode that does not require hardware support at all
|
KASan generic mode that does not require hardware support at all
|
||||||
|
|
||||||
config MM_KASAN_SW_TAGS
|
config MM_KASAN_SW_TAGS
|
||||||
bool "KAsan SW tags"
|
bool "KAsan SW tags"
|
||||||
select ARM64_TBI
|
select ARM64_TBI
|
||||||
|
select MM_KASAN_INSTRUMENT
|
||||||
depends on ARCH_ARM64
|
depends on ARCH_ARM64
|
||||||
---help---
|
---help---
|
||||||
KAsan based on software tags
|
KAsan based on software tags
|
||||||
|
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
config MM_KASAN_ALL
|
config MM_KASAN_INSTRUMENT_ALL
|
||||||
bool "Enable KASan for the entire image"
|
bool "Enable KASan for the entire image"
|
||||||
|
depends on MM_KASAN_INSTRUMENT
|
||||||
default y
|
default y
|
||||||
---help---
|
---help---
|
||||||
This option activates address sanitizer for the entire image.
|
This option activates address sanitizer for the entire image.
|
||||||
@@ -99,7 +105,7 @@ config MM_KASAN_SKIP_ZERO_TAGS
|
|||||||
|
|
||||||
config MM_KASAN_GLOBAL
|
config MM_KASAN_GLOBAL
|
||||||
bool "Enable global data check"
|
bool "Enable global data check"
|
||||||
depends on MM_KASAN_ALL
|
depends on MM_KASAN_INSTRUMENT_ALL
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
This option enables KASan global data check.
|
This option enables KASan global data check.
|
||||||
|
|||||||
Reference in New Issue
Block a user