[PATCH 0/5 v16] KASan for Arm

Arnd Bergmann arnd at kernel.org
Fri Oct 30 04:51:27 EDT 2020


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



More information about the linux-arm-kernel mailing list