Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 6 Mar 2018 14:41:55 -0800
From: Linus Torvalds <>
To: Steven Rostedt <>
Cc: Arnd Bergmann <>, Ard Biesheuvel <>, 
	Daniel Micay <>, Ingo Molnar <>, 
	Kees Cook <>, Dave Hansen <>, 
	Alexander Popov <>, 
	Kernel Hardening <>, PaX Team <>, 
	Brad Spengler <>, Andy Lutomirski <>, 
	Tycho Andersen <>, Laura Abbott <>, Mark Rutland <>, 
	Borislav Petkov <>, Richard Sandiford <>, 
	Thomas Gleixner <>, "H . Peter Anvin" <>, 
	Peter Zijlstra <>, "Dmitry V . Levin" <>, 
	Emese Revfy <>, Jonathan Corbet <>, 
	Andrey Ryabinin <>, 
	"Kirill A . Shutemov" <>, Thomas Garnier <>, 
	Andrew Morton <>, Alexei Starovoitov <>, Josef Bacik <>, 
	Masami Hiramatsu <>, Nicholas Piggin <>, 
	Al Viro <>, "David S . Miller" <>, 
	Ding Tianhong <>, David Woodhouse <>, 
	Josh Poimboeuf <>, Dominik Brodowski <>, 
	Juergen Gross <>, Greg Kroah-Hartman <>, 
	Dan Williams <>, Mathias Krause <>, 
	Vikas Shivappa <>, Kyle Huey <>, 
	Dmitry Safonov <>, Will Deacon <>, X86 ML <>, 
	LKML <>
Subject: Re: [PATCH RFC v9 4/7] x86/entry: Erase kernel stack in syscall_trace_enter()

On Tue, Mar 6, 2018 at 2:29 PM, Steven Rostedt <> wrote:
> Yeah but I would argue that static variables are different.

Not really.

You're basically saying "I'd like my language to have intrinsic
undefined behavior, so that when I hit a bug that might trigger that
undefined behavior I get a warning":.

Do such bugs happen? Sure. But _other_ bugs happen all the time, and
the ONLY real reason you are so adamant about _that_ particular
warning, is that "undefined behavior" is such a serious problem.

Think about that for a second.

Make the serious problem go away, and the warning MAKES NO SENSE.

Do you want a compiler to warn you when you write code like this:

    double area(double radius)
         return radius*2*pi;

just because it's obviously buggy shit?

And do you *really* expect a compiler warning for that kind of
obviously buggy shit?

I bet you don't.

And if you don't, why do you expect a compiler warning for

  int g(int c)
         int i = 0;
         if (c)
                 i = 1;
         return i;

which is *literally* what your example would have been had just C been
specified to avoid unnecessary undefined behavior?

Seriously. Look at that example, and tell me that gcc should warn
about it. I can imagine the warning ("warning: function 'g()' is
stupidly written, just use !!c").

But nobody sane really would expect a compiler to warn about it. Once
a compiler is that smart, you wouldn't write code for it, you'd just
ask it to generate code from a description.

Guys, everybody agrees that C isn't a safe language.

Do you think that lack of safety is a _good_ thing?

Do you realize that most of the lack of safety is almost directly
about flexibility, simplicity, and good code generation?

But what if I told you that some of the lack of safety doesn't
actually add to flexibility, simplicity, _or_ good code generation?
Wouldn't you say "we don't want it to be unsafe" then?

I'm literally telling you that lack of variable initialization is
almost purely a bad thing. C would be a safer language, with less
undefined behavior, if it just made the initialization of automatic
variables be something you cannot avoid.

For scalars in particular, there is basically no downside. Aggregate
types really are much less black-and-white.


Powered by blists - more mailing lists

Your e-mail address:

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