[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a2Rr1_+m245cBhS6EkKm9-ZgfVDNB0x-=RNJ3KrGEWBpQ@mail.gmail.com>
Date: Mon, 11 Mar 2019 21:58:55 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Ard Biesheuvel <ard.biesheuvel@...aro.org>
Cc: Russell King - ARM Linux admin <linux@...linux.org.uk>,
Mikael Pettersson <mikpelinux@...il.com>,
Peter Zijlstra <peterz@...radead.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
LKML <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...hat.com>,
Darren Hart <dvhart@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Dave Martin <Dave.Martin@....com>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH 2/2] ARM: futex: make futex_detect_cmpxchg more reliable
On Mon, Mar 11, 2019 at 5:36 PM Ard Biesheuvel
<ard.biesheuvel@...aro.org> wrote:
>
> On Mon, 11 Mar 2019 at 17:30, Arnd Bergmann <arnd@...db.de> wrote:
> >
> > On Mon, Mar 11, 2019 at 3:36 PM Ard Biesheuvel
> > <ard.biesheuvel@...aro.org> wrote:
> > > On Mon, 11 Mar 2019 at 15:34, Arnd Bergmann <arnd@...db.de> wrote:
> > > > On Fri, Mar 8, 2019 at 12:56 PM Ard Biesheuvel
> > > > <ard.biesheuvel@...aro.org> wrote:
> > > > > On Fri, 8 Mar 2019 at 11:58, Russell King - ARM Linux admin <linux@...linux.org.uk> wrote:
> > > > > > On Fri, Mar 08, 2019 at 11:45:21AM +0100, Ard Biesheuvel wrote:
> > > >
> > > > My first attempt (before finding the original patch from Mikael Pettersson)
> > > > was to change the probe to pass '1' as the value instead of '0', that
> > > > worked fine.
> > > >
> > >
> > > Which probe is that?
> >
> > diff --git a/kernel/futex.c b/kernel/futex.c
> > index c3b73b0311bc..19615ad3c4f7 100644
> > --- a/kernel/futex.c
> > +++ b/kernel/futex.c
> > @@ -3864,7 +3864,7 @@ static void __init futex_detect_cmpxchg(void)
> > * implementation, the non-functional ones will return
> > * -ENOSYS.
> > */
> > - if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
> > + if (cmpxchg_futex_value_locked(&curval, NULL, 1, 1) == -EFAULT)
> > futex_cmpxchg_enabled = 1;
> > #endif
> > }
> >
>
> Ah ok.
>
> That explains a lot.
>
> Can't we just return -EFAULT if uaddr is NULL? Or does that defeat this check?
I think that would work here, it would just create a tiny overhead
for each call to futex_atomic_cmpxchg_inatomic().
Semi-related side note:
After I looked at access_ok() for a bit too long, I tried replacing it with
#define access_ok(addr, size) \
(((u64)(uintptr_t)addr + (u64)(size_t)size) >=
current_thread_info()->addr_limit)
which interestingly seemed to improve the output with clang (it lets it
combine multiple access_ok() checks and schedule the instructions better,
compared to our inline asm implementation), but it unfortunately creates
horrible code with gcc.
Arnd
Powered by blists - more mailing lists