Subject: Re: [PATCH v13 (resend) 2/6] x86/entry: Add STACKLEAK erasing the kernel stack at the end of syscalls References: <1529686717-16017-1-git-send-email-alex.popov@linux.com> <1529686717-16017-3-git-send-email-alex.popov@linux.com> <3e319e96-e942-7c87-7b72-a5c3f520f234@redhat.com> From: Laura Abbott Message-ID: <172bdd35-e9b3-95ca-c1bc-58bd7894483b@redhat.com> Date: Tue, 26 Jun 2018 17:55:40 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit To: Kees Cook Cc: Alexander Popov , Kernel Hardening , PaX Team , Brad Spengler , Ingo Molnar , Andy Lutomirski , Tycho Andersen , 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 ML , LKML List-ID: On 06/26/2018 05:21 PM, Kees Cook wrote: > On Tue, Jun 26, 2018 at 5:13 PM, Kees Cook wrote: >> The only arch-specific part is current_top_of_stack(), so it seems >> like just solving current_top_of_stack() and copying on_thread_stack() >> directly should work, yes? I would think sticking those directly into >> asm/processor.h on arm64 would be okay? > > The difference in the earlier x86 and arm64 erase_kstack was: > > x86: > if (on_thread_stack()) > boundary = current_stack_pointer; > else > boundary = current_top_of_stack(); > > arm64: > boundary = current_stack_pointer; > > If a sane current_top_of_stack() isn't possible on arm64, I'm not > opposed to a small bit of arch-specific ifdef in there: > > boundary = get_stack_boundary(); > > static inline unsigned long get_stack_boundary(void) > { > #ifdef CONFIG_X86 > if (!on_thread_stack()) > return current_top_of_stack(); > #else > return current_stack_pointer; > } > > -Kees > I _think_ I have reasonable implementations for both functions, I was asking about pulling stuff out into a new header because I wanted to see about reusing on_task_stack which was defined in asm/stacktrace.h and I was concerned about include nightmares with asm/processor.h . I'll see what I come up with. Thanks, Laura