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] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 6 Mar 2017 15:14:08 +0100
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Jiri Slaby <jslaby@...e.cz>
Cc:     Stafford Horne <shorne@...il.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        Russell King - ARM Linux <linux@...linux.org.uk>,
        Andrew Morton <akpm@...ux-foundation.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Richard Henderson <rth@...ddle.net>,
        Ivan Kokshaysky <ink@...assic.park.msu.ru>,
        Matt Turner <mattst88@...il.com>,
        Vineet Gupta <vgupta@...opsys.com>,
        Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will.deacon@....com>,
        Richard Kuo <rkuo@...eaurora.org>,
        Tony Luck <tony.luck@...el.com>,
        Fenghua Yu <fenghua.yu@...el.com>,
        Michal Simek <monstr@...str.eu>,
        Ralf Baechle <ralf@...ux-mips.org>,
        Jonas Bonn <jonas@...thpole.se>,
        Stefan Kristiansson <stefan.kristiansson@...nalahti.fi>,
        "James E.J. Bottomley" <jejb@...isc-linux.org>,
        Helge Deller <deller@....de>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Paul Mackerras <paulus@...ba.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Martin Schwidefsky <schwidefsky@...ibm.com>,
        Heiko Carstens <heiko.carstens@...ibm.com>,
        Yoshinori Sato <ysato@...rs.sourceforge.jp>,
        Rich Felker <dalias@...c.org>, DavidS.Miller@...or.com
Subject: Re: [PATCH 1/3] futex: remove duplicated code

Hi Jiri,

On Mon, Mar 6, 2017 at 9:46 AM, Jiri Slaby <jslaby@...e.cz> wrote:
>     futex: make the encoded_op decoding readable
>
>     Decoding of encoded_op is a bit unreadable. It contains shifts to the
>     left and to the right by some constants. Make it clearly visible what
>     part of the bit mask is taken and shift the values only to the right
>     appropriately. And make sure sign extension takes place using
>     sign_extend32.
>
>     Signed-off-by: Jiri Slaby <jslaby@...e.cz>
>
> diff --git a/kernel/futex.c b/kernel/futex.c
> index 0ead0756a593..f90314bd42cb 100644
> --- a/kernel/futex.c
> +++ b/kernel/futex.c
> @@ -1461,10 +1461,10 @@ futex_wake(u32 __user *uaddr, unsigned int
> flags, int nr_wake, u32 bitset)
>
>  static int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
>  {
> -       int op = (encoded_op >> 28) & 7;
> -       int cmp = (encoded_op >> 24) & 15;

At least for the two above (modulo 7 vs 15?), the old decoding code matched
the flow of operation in FUTEX_OP().

> -       int oparg = (encoded_op << 8) >> 20;
> -       int cmparg = (encoded_op << 20) >> 20;
> +       int op =                  (encoded_op & 0x70000000) >> 28;
> +       int cmp =                 (encoded_op & 0x0f000000) >> 24;
> +       int oparg = sign_extend32((encoded_op & 0x00fff000) >> 12, 12);
> +       int cmparg = sign_extend32(encoded_op & 0x00000fff, 12);
>         int oldval, ret;

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists