Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 14 Mar 2018 09:38:07 -0700
From: Linus Torvalds <>
To: Florian Weimer <>
Cc: Kees Cook <>, Ingo Molnar <>, 
	P J P <>, Ard Biesheuvel <>, 
	Steven Rostedt <>, Arnd Bergmann <>, 
	Daniel Micay <>, 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: Fully initialized stack usage (was Re: [PATCH RFC v9 4/7]
 x86/entry: Erase kernel stack in syscall_trace_enter())

On Wed, Mar 14, 2018 at 9:29 AM, Linus Torvalds
<> wrote:
> The second one results in good code:
>         movl    $0, 16(%rsp)
>         movl    $123, 20(%rsp)
> which is good and doesn't leave the padding uninitialized

Side note: this obviously implies that your patch already fixes
things, but funnily, it only if the structure didn't have an

IOW, with your patch,

        struct a a;

        a = (struct a) ( 1, 2 };

would do the right thing for us because of an odd internal gcc
implementation detail, because that initial definition of 'a' doesn't
have an initializer, so your patch adds an empty one, and gcc seems to
always treat that as "clear the whole stricture". After that, the
structure assignment works fine and leaves the padding zero.

But a plain

        struct a a = { 1, 2 };

doesn't DTRT, and leaves uninitialized bytes to be passed around.

Of course, there might be other special cases that I simply didn't
happen to trigger with my overly stupid example and testing. Maybe
sometimes gcc does structure copies or clearing using the
member-by-member model?

My quick testing seems to indicate that it's _only_ initializers that
cause this, whether they are part of the variable declaration or


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.