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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210913183813.GY2505917@nvidia.com>
Date:   Mon, 13 Sep 2021 15:38:13 -0300
From:   Jason Gunthorpe <jgg@...dia.com>
To:     Nick Desaulniers <ndesaulniers@...gle.com>
Cc:     kernel test robot <lkp@...el.com>,
        Nathan Chancellor <nathan@...nel.org>, llvm@...ts.linux.dev,
        kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        clang-built-linux@...glegroups.com
Subject: Re: drivers/infiniband/hw/qib/qib_sysfs.c:413:1: error:
 static_assert expression is not an integral constant expression

On Mon, Sep 13, 2021 at 10:00:02AM -0700, Nick Desaulniers wrote:

> > This macro would like to know that the passed in member name has a u64
> > type, all the things I've come up with fail on clang - but many work
> > fine on gcc. Frankly I think this case is a clang bug myself..
> 
> Perhaps, though this assertion looks a bit like offsetof() to me. I
> wonder if that can help here?

The assertion would logically like to be this:

         static_assert(typecheck(((struct qib_port *)0)->N, u64))

Which doesn't compile because typecheck is not a constexpr :\

typecheck also can't be used as a build bug on zero in the initializer
for the same reason.

My original attempt was

                .counter = &((struct qib_ibport *)0)->rvp.n_##N - (u64 *)0,    \

Which is fairly simple opencoding of offsetof_end but clang whines
overly pedantically that NULL subtraction is undefined behavior.

The current version is this:

       static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL);

Which *should* be perfectly fine, but clang explodes for some reason
complaining about -> on NULL. I think it is broken and doesn't
understand that this -> is not an actual deref but pointer/type logic,
much like this:

#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))

Which does work.

So to my mind clang is being buggy, and I'm probably going to just
delete the line and a give up on type checking here unless someone has
a better idea.

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ