All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Nathan Chancellor <natechancellor@gmail.com>
Cc: Sasha Levin <sashal@kernel.org>,
	stable@vger.kernel.org, clang-built-linux@googlegroups.com,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Kees Cook <keescook@chromium.org>,
	Nick Desaulniers <ndesaulniers@google.com>
Subject: Re: [PATCH 4.19] compiler.h: give up __compiletime_assert_fallback()
Date: Mon, 3 Jun 2019 09:58:26 +0200	[thread overview]
Message-ID: <20190603075826.GD7814@kroah.com> (raw)
In-Reply-To: <20190531060109.124476-1-natechancellor@gmail.com>

On Thu, May 30, 2019 at 11:01:10PM -0700, Nathan Chancellor wrote:
> From: Masahiro Yamada <yamada.masahiro@socionext.com>
> 
> commit 81b45683487a51b0f4d3b29d37f20d6d078544e4 upstream.
> 
> __compiletime_assert_fallback() is supposed to stop building earlier
> by using the negative-array-size method in case the compiler does not
> support "error" attribute, but has never worked like that.
> 
> You can simply try:
> 
>     BUILD_BUG_ON(1);
> 
> GCC immediately terminates the build, but Clang does not report
> anything because Clang does not support the "error" attribute now.
> It will later fail at link time, but __compiletime_assert_fallback()
> is not working at least.
> 
> The root cause is commit 1d6a0d19c855 ("bug.h: prevent double evaluation
> of `condition' in BUILD_BUG_ON").  Prior to that commit, BUILD_BUG_ON()
> was checked by the negative-array-size method *and* the link-time trick.
> Since that commit, the negative-array-size is not effective because
> '__cond' is no longer constant.  As the comment in <linux/build_bug.h>
> says, GCC (and Clang as well) only emits the error for obvious cases.
> 
> When '__cond' is a variable,
> 
>     ((void)sizeof(char[1 - 2 * __cond]))
> 
> ... is not obvious for the compiler to know the array size is negative.
> 
> Reverting that commit would break BUILD_BUG() because negative-size-array
> is evaluated before the code is optimized out.
> 
> Let's give up __compiletime_assert_fallback().  This commit does not
> change the current behavior since it just rips off the useless code.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> Reviewed-by: Kees Cook <keescook@chromium.org>
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> 
> Hi Greg and Sasha,
> 
> Please pick up this patch for 4.19. It fixes an insane amount of spam
> from the drivers/gpu/drm/i915 subsystem because they enable the -Wvla
> warning and we have been carrying it in our CI for a while.

Now applied, thanks.

greg k-h

      reply	other threads:[~2019-06-03  7:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31  6:01 [PATCH 4.19] compiler.h: give up __compiletime_assert_fallback() Nathan Chancellor
2019-06-03  7:58 ` Greg Kroah-Hartman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190603075826.GD7814@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=keescook@chromium.org \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.