Sender: Ingo Molnar Date: Tue, 6 Mar 2018 09:08:55 +0100 From: Ingo Molnar Subject: Re: [PATCH RFC v9 4/7] x86/entry: Erase kernel stack in syscall_trace_enter() Message-ID: <20180306080855.phtgl2bzqm5hnthu@gmail.com> References: <1520107232-14111-1-git-send-email-alex.popov@linux.com> <1520107232-14111-5-git-send-email-alex.popov@linux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: To: Kees Cook Cc: Linus Torvalds , Dave Hansen , Alexander Popov , Kernel Hardening , PaX Team , Brad Spengler , Andy Lutomirski , Tycho Andersen , Laura Abbott , Mark Rutland , Ard Biesheuvel , 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 , Steven Rostedt , Dominik Brodowski , Juergen Gross , Greg Kroah-Hartman , Dan Williams , Mathias Krause , Vikas Shivappa , Kyle Huey , Dmitry Safonov , Will Deacon , Arnd Bergmann , X86 ML , LKML List-ID: * Kees Cook wrote: > [...] We've already seen multiple cases of this just with the by-ref > initialization plugin, where a stack content leak goes away because we asked the > compiler to please initialize the memory for us when we forgot to do it > ourselves. Getting the compiler to help us seems like the obviously correct > thing to do, since we're using such a memory-safety-unfriendly language. :) So the question is, are there any known classes of stack content leak that the following .config options: CONFIG_GCC_PLUGIN_STRUCTLEAK=y CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y ... do not handle, and for which leaks the best solution is such runtime stack clearing? Because the GCC plugins clearing automatic local variables are _way_ superior: - it's probably a heck of a lot cheaper to clear structs than it is to clear the stack in every system call... - it's probably also safer statistically, because if there _is_ a reference to an uninitialized piece of memory in the kernel it will be to zero, not to a user controlled value... Thanks, Ingo