[PATCH 0/5 v16] KASan for Arm
Nathan Chancellor
natechancellor at gmail.com
Fri Oct 30 05:09:45 EDT 2020
On Fri, Oct 30, 2020 at 09:51:27AM +0100, Arnd Bergmann wrote:
> On Fri, Oct 30, 2020 at 9:45 AM Nathan Chancellor
> <natechancellor at gmail.com> wrote:
> > On Fri, Oct 30, 2020 at 09:10:56AM +0100, Ard Biesheuvel wrote:
> > 4043 futex_hashsize = 1UL << futex_shift;
> > (gdb)
> > 4045 futex_detect_cmpxchg();
> > (gdb)
>
> I can't explain it, but I'd point out that futex_detect_cmpxchg() has caused
> problems in the past, with multiple patches for it proposed in the past
> and none of them merged. One of the patches I had sent for it was:
>
> commit 8232a8ffc332fa6a50296a51c4d85200a747256c
> Author: Arnd Bergmann <arnd at arndb.de>
> Date: Mon Mar 4 17:33:00 2019 +0100
>
> [SUBMITTED 20190307] futex: mark futex_detect_cmpxchg() as 'noinline'
>
> On 32-bit ARM, I got a link failure in futex_init() when building
> with clang in some random configurations:
>
> kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit:
> R_ARM_JUMP24 against `.init.text'
>
> As far as I can tell, the problem is that a branch is over 16MB
> apart in those configurations, but only if it branches back to
> the init text.
>
> Marking the futex_detect_cmpxchg() function as noinline and
> not __init avoids the problem for me.
>
> Signed-off-by: Arnd Bergmann <arnd at arndb.de>
>
> diff --git a/kernel/futex.c b/kernel/futex.c
> index e646661f6282..6fbbed45f51b 100644
> --- a/kernel/futex.c
> +++ b/kernel/futex.c
> @@ -4061,7 +4061,7 @@ SYSCALL_DEFINE6(futex_time32, u32 __user *,
> uaddr, int, op, u32, val,
> }
> #endif /* CONFIG_COMPAT_32BIT_TIME */
>
> -static void __init futex_detect_cmpxchg(void)
> +static noinline void futex_detect_cmpxchg(void)
> {
> #ifndef CONFIG_HAVE_FUTEX_CMPXCHG
> u32 curval;
>
> I forgot what the problem was, but you might try that patch, or find
> the previous discussions in the archive.
>
> Arnd
As it turns out, that is the patch that fixes the ld.bfd issue that I
mentioned earlier in this thread and it fixes this issue as well.
To summarize, with the below diff, I can successfully boot
multi_v7_defconfig + CONFIG_KASAN=y when LLVM=1 is used (and I see KASAN
get initialized properly).
Cheers,
Nathan
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 4d76eab2b22d..3c0a64cefe52 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -10,7 +10,7 @@
#
# Copyright (C) 1995-2001 by Russell King
-LDFLAGS_vmlinux := --no-undefined -X --pic-veneer
+LDFLAGS_vmlinux := --no-undefined -X --pic-veneer -z norelro
ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
LDFLAGS_vmlinux += --be8
KBUILD_LDFLAGS_MODULE += --be8
diff --git a/kernel/futex.c b/kernel/futex.c
index be68ac0d49ad..226bb20d175f 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -4004,7 +4004,7 @@ SYSCALL_DEFINE6(futex_time32, u32 __user *, uaddr, int, op, u32, val,
}
#endif /* CONFIG_COMPAT_32BIT_TIME */
-static void __init futex_detect_cmpxchg(void)
+static noinline void futex_detect_cmpxchg(void)
{
#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
u32 curval;
More information about the linux-arm-kernel
mailing list