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: <20211202061218.GA30793@kili>
Date:   Thu, 2 Dec 2021 09:12:18 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Miguel Ojeda <ojeda@...nel.org>
Cc:     Nathan Chancellor <nathan@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Kees Cook <keescook@...omium.org>,
        Peter Zijlstra <peterz@...radead.org>,
        linux-kernel@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH] compiler_types: mark __compiletime_assert failure as
 __noreturn

On Thu, Oct 14, 2021 at 03:23:31PM +0200, Miguel Ojeda wrote:
> `__compiletime_assert` declares a fake `extern` function
> which appears (to the compiler) to be called when the test fails.
> 
> Therefore, compilers may emit possibly-uninitialized warnings
> in some cases, even if it will be an error anyway (for compilers
> supporting the `error` attribute, e.g. GCC and Clang >= 14)
> or a link failure (for those that do not, e.g. Clang < 14).
> 
> Annotating the fake function as `__noreturn` gives them
> the information they need to avoid the warning,
> e.g. see https://godbolt.org/z/x1v69jjYY.
> 
> Link: https://lore.kernel.org/llvm/202110100514.3h9CI4s0-lkp@intel.com/
> Reported-by: kernel test robot <lkp@...el.com>
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>

This patch is kind of a headache for Smatch.

The patch basically turns BUILD_BUG() into BUG().  That's fine.

But it also turn BUILD_BUG_ON(!__builtin_constant_p(foo) into a BUG_ON().
A lot of places call BUILD_BUG_ON() to ensure that functions are inlined
and the build breaks if not.  For example, the FIELD_GET() macro will
trigger a build bug if "mask" is not a compile time constant.

   295  static __always_inline u32 cal_read_field(struct cal_dev *cal, u32 offset, u32 mask)
   296  {
   297          return FIELD_GET(mask, cal_read(cal, offset));
   298  }

Unfortunately, Smatch doesn't respect the __always_inline annotation so
now it thinks cal_read_field calls BUG() and records it as a noreturn
function.  And all the callers get marked as noreturn functions as well.

Could we make it so that BUILD_BUG() is a noreturn function and
BUILD_BUG_ON() is left as it was?

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ