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]
Message-ID: <20190801230350.GA4046@rikard>
Date:   Fri, 2 Aug 2019 01:03:50 +0200
From:   Rikard Falkeborn <rikard.falkeborn@...il.com>
To:     Joe Perches <joe@...ches.com>
Cc:     Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Rikard Falkeborn <rikard.falkeborn@...il.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Johannes Berg <johannes@...solutions.net>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] linux/bits.h: Add compile time sanity check of GENMASK
 inputs

On Wed, Jul 31, 2019 at 07:57:48PM -0700, Joe Perches wrote:
> On Thu, 2019-08-01 at 11:50 +0900, Masahiro Yamada wrote:
> > On Thu, Aug 1, 2019 at 4:04 AM Rikard Falkeborn
> > <rikard.falkeborn@...il.com> wrote:
> > > GENMASK() and GENMASK_ULL() are supposed to be called with the high bit
> > > as the first argument and the low bit as the second argument. Mixing
> > > them will return a mask with zero bits set.
> > 
> > This is getting cluttered with so many parentheses.
> > 
> > One way of clean-up is to rename the current macros as follows:
> > 
> >    GENMASK()    ->  __GENMASK()
> >    GENMASK_UL() ->  __GENMASK_ULL()
> > 
> > Then,
> > 
> > #define GENMASK(h, l)       (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
> > #define GENMASK_ULL(h, l)   (GENMASK_INPUT_CHECK(h, l) + __GENMASK_ULL(h, l))
> 
> Much nicer.  It may be better still to use avoid
> multiple dereferences of each argument.

Much nicer indeed, I changed it accordingly. There are no multiple
dererences of the arguments. GENMASK_INPUT_CHECK() and __is_constexpr()
both use sizeof() on the input arguments, which does not evaluate the
argument (unless the argument is a VLA, which is not allowed).
 
> Also it'd be useful to rename h and l to something like
> high_bit and low_bit or high and low.

Agreed.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ