Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 11 Mar 2018 11:23:29 -0700
From: Linus Torvalds <>
To: Ingo Molnar <>
Cc: Miguel Ojeda <>, Kees Cook <>, 
	Randy Dunlap <>, Andrew Morton <>, 
	linux-kernel <>, Josh Poimboeuf <>, 
	Rasmus Villemoes <>, "Gustavo A. R. Silva" <>, 
	"Tobin C. Harding" <>, Steven Rostedt <>, Jonathan Corbet <>, 
	Chris Mason <>, Josef Bacik <>, David Sterba <>, 
	"David S. Miller" <>, Alexey Kuznetsov <>, 
	Hideaki YOSHIFUJI <>, Peter Zijlstra <>, 
	Thomas Gleixner <>, Masahiro Yamada <>, 
	Borislav Petkov <>, Ian Abbott <>, 
	Sergey Senozhatsky <>, Petr Mladek <>, 
	Andy Shevchenko <>, 
	Pantelis Antoniou <>, Linux Btrfs <>, 
	Network Development <>, 
	Kernel Hardening <>
Subject: Re: [PATCH v3] kernel.h: Skip single-eval logic on literals in min()/max()

On Sun, Mar 11, 2018 at 4:05 AM, Ingo Molnar <> wrote:
> BTW., while I fully agree with everything you said, it's not entirely correct to
> claim that if a C compiler can generate VLA code it is necessarily able to parse
> and evaluate constant array sizes "just fine".
> Constant expressions are typically parsed very early on, at the preprocessing
> stage. They can be used with some preprocessor directives as well, such as '#if'
> (with some further limitations on their syntax).

Yes. But constant simplification and CSE etc is just a very
fundamental part of a compiler, and anybody who actually implements
VLA's would have to do it anyway.

So no, a message like

  warning: Array declaration is not a C90 constant expression,
resulting in VLA code generation

would be moronic. Only some completely mindless broken shit would do
"oh, it's not a parse-time constant, so it will be variable". The two
just do not follow AT ALL.

So the message might be about _possibly_ resulting in VLA code
generation, but honestly, at that point you should just add the
warning when you actually generate the code to do the stack

Because at that point, you know whether it's variable or not.

And trust me, it won't be variable for things like (2,3), or even for
our "max()" thing with other odd builtins. Not unless the compiler
doesn't really support VLA at all (maybe some bolted-on crazy thing
that just turns a VLA at the front-end time into just an alloca), or
the user has explicitly asked to disable some fundamental optimization


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.