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: <CAK7LNAQ-i0T7sZBg5baFTXEwekbhWVLDSfOKCmHmNX-gHd5JHA@mail.gmail.com>
Date:   Sun, 26 Aug 2018 03:11:38 +0900
From:   Masahiro Yamada <yamada.masahiro@...ionext.com>
To:     Daniel Santos <daniel.santos@...ox.com>
Cc:     Nick Desaulniers <ndesaulniers@...gle.com>,
        Kees Cook <keescook@...omium.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        James Hogan <james.hogan@...tec.com>,
        Joe Stringer <joe@....org>,
        Rusty Russell <rusty@...tcorp.com.au>,
        Arnd Bergmann <arnd@...db.de>,
        Christopher Li <sparse@...isli.org>,
        linux-sparse@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
        George Burgess <gbiv@...gle.com>,
        James Y Knight <jyknight@...gle.com>
Subject: Re: [RFC PATCH] compiler.h: give up __compiletime_assert_fallback()

Hi Daniel,


2018-08-21 17:11 GMT+09:00 Daniel Santos <daniel.santos@...ox.com>:
> On 08/19/2018 03:25 PM, Nick Desaulniers wrote:
>> + gbiv who wrote this cool paste (showing alternatives to
>> _Static_assert, which is supported by both compilers in -std=gnu89,
>> but not until gcc 4.6): https://godbolt.org/g/DuLsxu
>>
>> I can't help but think that BUILD_BUG_ON_MSG should use
>> _Static_assert, then have fallbacks for gcc < 4.6.
>
> Unfortunately _Static_assert is a woefully inadequate replacement
> because it requires a C constant expression.  Example:
>
>     int a = 1;
>     _Static_assert(a == 1, "a != 1");
>
> results in "error: expression in static assertion is not constant."


You are right.




I tried diagnose_if from Clang:

static inline void assert_d(int i) __attribute__((diagnose_if(!i, "oh
no", "error")))
{
}



Clang is silent about

       int a = 1;
       assert_d(a);




But,

       if (0)
              assert_d(0);


is error.

Hence, it cannot be used for BUILD_BUG().







Anyway, I will just try to rebase this patch and send it to Linus.



> Language standards tend to shy away from defining implementation details
> like optimizations, but we need to have completed a good data flow
> analysis and constant propagation in order to do BUILD_BUG_ON_MSG, et.
> al.; this is why they only work when optimizations are enabled.  As the
> optimizer improves, new expressions can be used with BUILD_BUG_ON*.  I
> did an analysis of this back in 2012 of how various types of variables
> could be resolved to constants at compile-time and how that evolved from
> gcc 3.4 to 4.7:
>
> https://drive.google.com/open?id=1cQRAAOzjFy6Aw7CDc4QauHvd_spVkd5a
>
> This changed again when -findirect-inline was added -- i.e.,
> BUILD_BUG_ON could be used on parameters of inline functions even when
> called by pointer, although the caller needed __flatten in some cases --
> a bit messy.
>
> Daniel



-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ