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: <24c5699b-d222-486b-6f16-7539e931c436@linux.com> Date: Thu, 24 May 2018 16:05:27 +0300 MIME-Version: 1.0 In-Reply-To: <20180518065349.GA10080@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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: On 18.05.2018 09:53, Ingo Molnar wrote: > * Alexander Popov wrote: >> + if (on_thread_stack()) >> + boundary = current_stack_pointer; >> + else >> + boundary = current_top_of_stack(); >> + >> + BUG_ON(boundary - p >= THREAD_SIZE); > > Please make this: > > if ( WARN_ON_ONCE()) > return; > > ... or so, so that if this code is buggy we get actual useful user reports, not > just "my machine froze, help!"... I've just double-checked that BUG() in erase_kstack() works fine when it's called from the trampoline stack and thread stack. But this "WARN_ON_ONCE() + return" logic would introduce an undesirable effect: modifying 'lowest_stack' value would allow to silently skip stack erasing. Best regards, Alexander