From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Kees Cook <keescook@chromium.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Florian Weimer <fweimer@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Randy Dunlap <rdunlap@infradead.org>,
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
Ingo Molnar <mingo@kernel.org>,
David Laight <David.Laight@aculab.com>,
Ian Abbott <abbotti@mev.co.uk>,
linux-input <linux-input@vger.kernel.org>,
linux-btrfs <linux-btrfs@vger.kernel.org>,
Network Development <netdev@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Kernel Hardening <kernel-hardening@lists.openwall.com>
Subject: Re: [PATCH v5 0/2] Remove false-positive VLAs when using max()
Date: Sun, 18 Mar 2018 22:13:28 +0100 [thread overview]
Message-ID: <42b4342b-aefc-a16a-0d43-9f9c0d63ba7a@rasmusvillemoes.dk> (raw)
In-Reply-To: <CA+55aFwv0VC67cx2W9yrf7qSFKf6ncVRrsVyLGqdmfSBn4yTYw@mail.gmail.com>
On 2018-03-17 19:52, Linus Torvalds wrote:
> On Sat, Mar 17, 2018 at 12:27 AM, Kees Cook <keescook@chromium.org> wrote:
>>
>> Unfortunately my 4.4 test fails quickly:
>>
>> ./include/linux/jiffies.h: In function ‘jiffies_delta_to_clock_t’:
>> ./include/linux/jiffies.h:444: error: first argument to
>> ‘__builtin_choose_expr’ not a constant
>
> Ok, so it really looks like that same "__builtin_constant_p() doesn't
> return a constant".
>
> Which is really odd, but there you have it.
Not really. We do rely on builtin_constant_p not being folded too
quickly to a 0/1 answer, so that gcc still generates good code even if
the argument is only known to be constant at a late(r) optimization
stage (through inlining and all). So unlike types_compatible_p, which
can obviously be answered early during parsing, builtin_constant_p is
most of the time a yes/no/maybe/it's complicated thing. Sure, when the
argument is just a literal or perhaps even any kind of ICE, gcc can fold
it to "yes", and I think it does (though the details of when and if gcc
does that can obviously be very version-dependent, which may be some of
what we've seen). But when it's not that obvious, gcc leaves it in the
undetermined state. That's not good enough for builtin_choose_expr,
because even the type of the resulting expression depends on that first
argument, so that really must be resolved early.
So to have some kind of builtin_constant_p control a
builtin_choose_expr, it would need to be a "builtin_ice_p" or
"builtin_obviously_constant_p" that would always be folded to 0/1 as
part of evaluating ICEs.
So I don't think there's any way around creating a separate macro for
use with compile-time constants.
Rasmus
next prev parent reply other threads:[~2018-03-18 21:13 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-16 4:25 [PATCH v5 0/2] Remove false-positive VLAs when using max() Kees Cook
2018-03-16 4:25 ` [PATCH v5 1/2] kernel.h: Introduce const_max_t() for VLA removal Kees Cook
2018-03-16 4:25 ` [PATCH v5 2/2] Remove false-positive VLAs when using max() Kees Cook
2018-03-19 10:45 ` Andrey Ryabinin
2018-03-16 11:47 ` [PATCH v5 0/2] " Florian Weimer
2018-03-16 17:29 ` Linus Torvalds
2018-03-16 17:32 ` Florian Weimer
2018-03-16 17:44 ` David Laight
2018-03-16 20:25 ` Linus Torvalds
2018-03-16 17:55 ` Al Viro
2018-03-16 18:14 ` Al Viro
2018-03-16 19:27 ` Linus Torvalds
2018-03-16 20:03 ` Miguel Ojeda
2018-03-16 20:14 ` Linus Torvalds
2018-03-16 20:19 ` Linus Torvalds
2018-03-17 0:48 ` Miguel Ojeda
2018-03-17 1:49 ` Miguel Ojeda
2018-03-16 20:12 ` Al Viro
2018-03-16 20:15 ` Linus Torvalds
2018-03-16 20:18 ` Al Viro
2018-03-17 7:27 ` Kees Cook
2018-03-17 18:52 ` Linus Torvalds
2018-03-17 20:07 ` Kees Cook
2018-03-17 22:55 ` Josh Poimboeuf
2018-03-20 23:23 ` Linus Torvalds
2018-03-20 23:26 ` Linus Torvalds
2018-03-21 0:05 ` Al Viro
2018-03-22 15:01 ` Kees Cook
2018-03-22 15:13 ` David Laight
2018-03-22 17:04 ` Linus Torvalds
2018-03-18 21:13 ` Rasmus Villemoes [this message]
2018-03-18 21:33 ` Linus Torvalds
2018-03-18 22:59 ` Rasmus Villemoes
2018-03-18 23:36 ` Linus Torvalds
2018-03-19 9:43 ` David Laight
2018-03-19 23:29 ` Linus Torvalds
2018-03-20 3:10 ` Arnd Bergmann
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=42b4342b-aefc-a16a-0d43-9f9c0d63ba7a@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=David.Laight@aculab.com \
--cc=abbotti@mev.co.uk \
--cc=akpm@linux-foundation.org \
--cc=fweimer@redhat.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).