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, 13 Jan 2020 11:31:56 -0800
From:   Linus Torvalds <torvalds@...ux-foundation.org>
To:     Will Deacon <will@...nel.org>
Cc:     Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        linux-arch <linux-arch@...r.kernel.org>,
        Android Kernel Team <kernel-team@...roid.com>,
        Michael Ellerman <mpe@...erman.id.au>,
        Peter Zijlstra <peterz@...radead.org>,
        Segher Boessenkool <segher@...nel.crashing.org>,
        Christian Borntraeger <borntraeger@...ibm.com>,
        Luc Van Oostenryck <luc.vanoostenryck@...il.com>,
        Arnd Bergmann <arnd@...db.de>
Subject: Re: [RFC PATCH 6/8] READ_ONCE: Drop pointer qualifiers when reading
 from scalar types

On Mon, Jan 13, 2020 at 7:00 AM Will Deacon <will@...nel.org> wrote:
>
> I can't disagree with that, but the only option we've come up with so far
> that solves this in the READ_ONCE() macro itself is the thing from PeterZ:
>
> // Insert big fat comment here
> #define unqual_typeof(x)    typeof(({_Atomic typeof(x) ___x __maybe_unused; ___x; }))

I'm with Luc on this - that not only looks gcc-specific, it looks
fragile too, in that it's not obvious that "_Atomic typeof(x)" really
is guaranteed to do what we want.

> So I suppose my question is: how ill does this code really make you feel?

I wish the code was more obvious.

One way to do that might be to do your approach, but just write it as
a series of macros that makes it a bit more understandable what it
does.

Maybe it's just because of a "pee in the snow" effect, but I think
this is easier to explain:

  #define __pick_scalar_type(x,type,otherwise)          \
        __builtin_choose_expr(__same_type(x,type), (type)0, otherwise)

  #define __pick_integer_type(x, type, otherwise)       \
        __pick_scalar_type(x, unsigned type,            \
          __pick_scalar_type(x, signed type, otherwise))

  #define __unqual_scalar_typeof(x) typeof(             \
        __pick_integer_type(x, char,                    \
          __pick_integer_type(x, short,                 \
            __pick_integer_type(x, int,                 \
              __pick_integer_type(x, long,              \
                __pick_integer_type(x, long long, x))))))

just because you there's less repeated noise, and the repetition there
is is simpler.

So still "Eww", but maybe not quite _as_ "Eww".

             Linus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ