|
Message-ID: <20160624153001.b5urlxdpvliqqqji@treble> Date: Fri, 24 Jun 2016 10:30:01 -0500 From: Josh Poimboeuf <jpoimboe@...hat.com> To: Andy Lutomirski <luto@...nel.org> Cc: x86@...nel.org, linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org, Borislav Petkov <bp@...en8.de>, Nadav Amit <nadav.amit@...il.com>, Kees Cook <keescook@...omium.org>, Brian Gerst <brgerst@...il.com>, "kernel-hardening@...ts.openwall.com" <kernel-hardening@...ts.openwall.com>, Linus Torvalds <torvalds@...ux-foundation.org>, Jann Horn <jann@...jh.net>, Heiko Carstens <heiko.carstens@...ibm.com> Subject: Re: [PATCH v4 11/16] x86/dumpstack: When OOPSing, rewind the stack before do_exit On Thu, Jun 23, 2016 at 09:23:06PM -0700, Andy Lutomirski wrote: > If we call do_exit with a clean stack, we greatly reduce the risk of > recursive oopses due to stack overflow in do_exit, and we allow > do_exit to work even if we OOPS from an IST stack. The latter gives > us a much better chance of surviving long enough after we detect a > stack overflow to write out our logs. > > I intentionally separated this from the preceding patch that > disables do_exit-on-OOPS on IST stacks. This way, if we need to > revert this patch, we still end up in an acceptable state wrt stack > overflow handling. > > Signed-off-by: Andy Lutomirski <luto@...nel.org> > --- > arch/x86/entry/entry_32.S | 11 +++++++++++ > arch/x86/entry/entry_64.S | 11 +++++++++++ > arch/x86/kernel/dumpstack.c | 13 +++++++++---- > 3 files changed, 31 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S > index 983e5d3a0d27..0b56666e6039 100644 > --- a/arch/x86/entry/entry_32.S > +++ b/arch/x86/entry/entry_32.S > @@ -1153,3 +1153,14 @@ ENTRY(async_page_fault) > jmp error_code > END(async_page_fault) > #endif > + > +ENTRY(rewind_stack_do_exit) > + /* Prevent any naive code from trying to unwind to our caller. */ > + xorl %ebp, %ebp > + > + movl PER_CPU_VAR(cpu_current_top_of_stack), %esi > + leal -TOP_OF_KERNEL_STACK_PADDING-PTREGS_SIZE(%esi), %esp > + > + call do_exit > +1: jmp 1b > +END(rewind_stack_do_exit) > diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S > index 9ee0da1807ed..b846875aeea6 100644 > --- a/arch/x86/entry/entry_64.S > +++ b/arch/x86/entry/entry_64.S > @@ -1423,3 +1423,14 @@ ENTRY(ignore_sysret) > mov $-ENOSYS, %eax > sysret > END(ignore_sysret) > + > +ENTRY(rewind_stack_do_exit) > + /* Prevent any naive code from trying to unwind to our caller. */ > + xorl %ebp, %ebp s/ebp/rbp/g/ ? -- Josh
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.