riscv: Add ARCH_HAS_FORTIFY_SOURCE
authorKefeng Wang <wangkefeng.wang@huawei.com>
Thu, 25 Feb 2021 07:03:03 +0000 (15:03 +0800)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Wed, 10 Mar 2021 02:18:31 +0000 (18:18 -0800)
FORTIFY_SOURCE could detect various overflows at compile and run time.
ARCH_HAS_FORTIFY_SOURCE means that the architecture can be built and
run with CONFIG_FORTIFY_SOURCE. Select it in RISCV.

See more about this feature from commit 6974f0c4555e
("include/linux/string.h: add the option of fortified string.h functions").

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
arch/riscv/Kconfig
arch/riscv/include/asm/string.h

index 85d626b8ce5e07667bac85e76dd3c1a2eaaf9453..6978b0739718cbba8835bf3640fc57ce372a1551 100644 (file)
@@ -20,6 +20,7 @@ config RISCV
        select ARCH_HAS_DEBUG_VM_PGTABLE
        select ARCH_HAS_DEBUG_VIRTUAL if MMU
        select ARCH_HAS_DEBUG_WX
+       select ARCH_HAS_FORTIFY_SOURCE
        select ARCH_HAS_GCOV_PROFILE_ALL
        select ARCH_HAS_GIGANTIC_PAGE
        select ARCH_HAS_KCOV
index 5477e7ecb6e1633db9c2c4de9b78f596ba84e440..9090493665555c0d12248aae799c80509c2deadc 100644 (file)
@@ -23,5 +23,10 @@ extern asmlinkage void *__memmove(void *, const void *, size_t);
 #define memcpy(dst, src, len) __memcpy(dst, src, len)
 #define memset(s, c, n) __memset(s, c, n)
 #define memmove(dst, src, len) __memmove(dst, src, len)
+
+#ifndef __NO_FORTIFY
+#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */
+#endif
+
 #endif
 #endif /* _ASM_RISCV_STRING_H */