diff mbox series

fixup! ARM: Replace string mem* functions for KASan

Message ID 20201014105958.21027-1-a.fatoum@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series fixup! ARM: Replace string mem* functions for KASan | expand

Commit Message

Ahmad Fatoum Oct. 14, 2020, 10:59 a.m. UTC
CONFIG_FORTIFY_SOURCE doesn't play nicely for files that are compiled
with CONFIG_KASAN=y, but have sanitization disabled.

This happens despite 47227d27e2fc ("string.h: fix incompatibility between
FORTIFY_SOURCE and KASAN"). For now, do what ARM64 is already doing and
disable FORTIFY_SOURCE for such files.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
CONFIG_FORTIFY_SOURCE kernel on i.MX6Q hangs indefinitely in a
memcpy inside the very first printk without this patch.

With this patch squashed:
Tested-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/include/asm/string.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Linus Walleij Oct. 19, 2020, 8:36 a.m. UTC | #1
On Wed, Oct 14, 2020 at 1:00 PM Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:

> CONFIG_FORTIFY_SOURCE doesn't play nicely for files that are compiled
> with CONFIG_KASAN=y, but have sanitization disabled.
>
> This happens despite 47227d27e2fc ("string.h: fix incompatibility between
> FORTIFY_SOURCE and KASAN"). For now, do what ARM64 is already doing and
> disable FORTIFY_SOURCE for such files.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> CONFIG_FORTIFY_SOURCE kernel on i.MX6Q hangs indefinitely in a
> memcpy inside the very first printk without this patch.
>
> With this patch squashed:
> Tested-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Thanks so much Ahmad! I folded in your fix into this patch and
added your Signed-off-by then added your Tested-by on all
patches and will resend as v16 before putting this into Russell's
patch tracker.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/arch/arm/include/asm/string.h b/arch/arm/include/asm/string.h
index 947f93037d87..6c607c68f3ad 100644
--- a/arch/arm/include/asm/string.h
+++ b/arch/arm/include/asm/string.h
@@ -58,6 +58,11 @@  static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n)
 #define memcpy(dst, src, len) __memcpy(dst, src, len)
 #define memmove(dst, src, len) __memmove(dst, src, len)
 #define memset(s, c, n) __memset(s, c, n)
+
+#ifndef __NO_FORTIFY
+#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */
+#endif
+
 #endif
 
 #endif