From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: Re: [PATCH v12 2/6] x86/entry: Add STACKLEAK erasing the kernel stack at the end of syscalls References: <1526488097-20611-1-git-send-email-alex.popov@linux.com> <1526488097-20611-3-git-send-email-alex.popov@linux.com> <20180518065349.GA10080@gmail.com> From: Alexander Popov Message-ID: <23369d86-ad31-e7c5-e42f-28e0e51ec128@linux.com> Date: Tue, 22 May 2018 13:58:59 +0300 MIME-Version: 1.0 In-Reply-To: <20180518065349.GA10080@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: Ingo Molnar , Kees Cook Cc: kernel-hardening@lists.openwall.com, 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 , Linus Torvalds , Greg Kroah-Hartman , Dan Williams , Dave Hansen , Mathias Krause , Vikas Shivappa , Kyle Huey , Dmitry Safonov , Will Deacon , Arnd Bergmann , Florian Weimer , Boris Lukashev , Andrey Konovalov , x86@kernel.org, linux-kernel@vger.kernel.org List-ID: Hello Ingo and Kees, On 18.05.2018 09:53, Ingo Molnar wrote: > * Alexander Popov wrote: >> --- a/arch/x86/kernel/process_32.c >> +++ b/arch/x86/kernel/process_32.c >> @@ -136,6 +136,11 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long sp, >> p->thread.sp0 = (unsigned long) (childregs+1); >> memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps)); >> >> +#ifdef CONFIG_GCC_PLUGIN_STACKLEAK >> + p->thread.lowest_stack.val = (unsigned long)end_of_stack(p) + >> + sizeof(unsigned long); >> +#endif > > This should use an inline helper: > > stackleak_task_init(p); Right now I can't define such a helper because 'lowest_stack' is a part of 'thread_struct', but arch/x86/include/asm/processor.h and include/linux/sched.h are independent. I think the best solution is to move 'lowest_stack' variable to 'task_struct'. Is there any reason to fold this variable into a 'stackleak_info' structure? I see everybody happily uses #ifdef in 'task_struct'. May I define STACKLEAK_POISON and STACKLEAK_POISON_CHECK_DEPTH in sched.h as well? Looking forward to your reply. Best regards, Alexander