lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAG_fn=VAjx4iM8zdQnLY-nbbb09PEcwfzk3zbEWoCYxtjrnE-g@mail.gmail.com>
Date:   Tue, 2 Apr 2019 13:31:57 +0200
From:   Alexander Potapenko <glider@...gle.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Paul McKenney <paulmck@...ux.ibm.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        LKML <linux-kernel@...r.kernel.org>,
        Dmitriy Vyukov <dvyukov@...gle.com>,
        James Y Knight <jyknight@...gle.com>, x86@...nel.org,
        Ingo Molnar <mingo@...hat.com>
Subject: Re: [PATCH] x86/asm: use memory clobber in bitops that touch
 arbitrary memory

On Tue, Apr 2, 2019 at 10:59 AM Alexander Potapenko <glider@...gle.com> wrote:
>
> On Tue, Apr 2, 2019 at 9:27 AM Peter Zijlstra <peterz@...radead.org> wrote:
> >
> >
> >
> > On Mon, Apr 01, 2019 at 06:24:08PM +0200, Alexander Potapenko wrote:
> > > diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
> > > index d153d570bb04..20e4950827d9 100644
> > > --- a/arch/x86/include/asm/bitops.h
> > > +++ b/arch/x86/include/asm/bitops.h
> > > @@ -111,7 +111,7 @@ clear_bit(long nr, volatile unsigned long *addr)
> > >       } else {
> > >               asm volatile(LOCK_PREFIX __ASM_SIZE(btr) " %1,%0"
> > >                       : BITOP_ADDR(addr)
> > > -                     : "Ir" (nr));
> > > +                     : "Ir" (nr) : "memory");
> > >       }
> > >  }
> >
> > clear_bit() doesn't have a return value, so why are we now still using
> > "+m" output ?
> You're right, "m" should suffice. I'll update the patch.
> By the way, now that we've added the memory barriers we can probably
> remove the barrier() call from __clear_bit_unlock() and update the
> comment accordingly.
> For clear_bit() the memory barrier is missing on the IS_IMMEDIATE(nr)
> path, so this one should be kept as is.
>
> > AFAICT the only reason we did that was to clobber the variable, which
> > you've (afaiu correctly) argued to be incorrect.
> >
> > So whould we not write this as:
> >
> >         asm volatile (LOCK_PREFIX __ASM_SIZE(btr) " %[nr], %[addr]"
> >                 : : [addr] "m" (*addr), [nr] "Ir" (nr)
> >                 : "memory");
Updated the patch.
I took the liberty of not adding the symbolic names to reduce the diff.
If you think that's necessary I can do that in a separate patch.
> > ?
> >
> > And the very same for _all_ other sites touched in this patch.
>
>
>
> --
> Alexander Potapenko
> Software Engineer
>
> Google Germany GmbH
> Erika-Mann-Straße, 33
> 80636 München
>
> Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
> Registergericht und -nummer: Hamburg, HRB 86891
> Sitz der Gesellschaft: Hamburg



-- 
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ