Date: Mon, 5 Mar 2018 21:26:52 +0100 From: Peter Zijlstra Subject: Re: [PATCH RFC v9 4/7] x86/entry: Erase kernel stack in syscall_trace_enter() Message-ID: <20180305202652.GY25201@hirez.programming.kicks-ass.net> 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: Dave Hansen , Alexander Popov , Kernel Hardening , PaX Team , Brad Spengler , Ingo Molnar , Andy Lutomirski , Tycho Andersen , Laura Abbott , Mark Rutland , Ard Biesheuvel , Borislav Petkov , Richard Sandiford , Thomas Gleixner , "H . Peter Anvin" , "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: On Mon, Mar 05, 2018 at 12:06:18PM -0800, Kees Cook wrote: > On Mon, Mar 5, 2018 at 11:40 AM, Dave Hansen > wrote: > > On 03/03/2018 12:00 PM, Alexander Popov wrote: > >> @@ -128,6 +134,7 @@ static long syscall_trace_enter(struct pt_regs *regs) > >> > >> do_audit_syscall_entry(regs, arch); > >> > >> + erase_kstack(); > >> return ret ?: regs->orig_ax; > >> } > > > > This seems like an odd place to be clearing the stack. Why was it done her? > > Perhaps the commit log could be improved, but the idea is that the > audit work (ptrace, seccomp, etc), is happening before the syscall > code starts running, and it has therefore written to the stack (that > used to be cleared on last exit). This retains the clear stack state > even in the face of ptrace-ish work happening before the syscall > proper starts. I'd suggest a code-comment over a Changelog twiddle. The changelog bit only helps now, that code comments helps us again in 6 motnhs time when we've forgotten everything again.