Skip to contentSkip to conversation

riscv: Add ARCH_HAS_FORTIFY_SOURCE

PATCH In review Kefeng Wang 2 participants 2 messages Feb 25, 2021 – Mar 10, 2021 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: Add ARCH_HAS_FORTIFY_SOURCE

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").

---
 arch/riscv/Kconfig              | 1 +
 arch/riscv/include/asm/string.h | 5 +++++
 2 files changed, 6 insertions(+)
arch/riscv/Kconfig +1 -0
index 53e66347366f..fa30fbf66879 100644
@@ -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
arch/riscv/include/asm/string.h +5 -0
index 5477e7ecb6e1..909049366555 100644
@@ -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 */
Signature · 7 lines
2.17.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
maintainer
#1 lore raw
Quoted 30 lines · On Wed, 24 Feb 2021 23:03:03 PST (-0800), [email protected] wrote:

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").

---
 arch/riscv/Kconfig              | 1 +
 arch/riscv/include/asm/string.h | 5 +++++
 2 files changed, 6 insertions(+)
arch/riscv/Kconfig +1 -0
index 53e66347366f..fa30fbf66879 100644
@@ -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
arch/riscv/include/asm/string.h +0 -0
index 5477e7ecb6e1..909049366555 100644

arch/riscv/include/asm/string.h extern asmlinkage void *__memmove(void *, const void *, size_t); · line 32

Quoted 10 lines
arch/riscv/include/asm/string.h +5 -0
@@ -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 */

Thanks, this is on for-next.

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv