Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1174439 > unrolled thread

Re: [PATCH v4 02/17] x86/entry/64/compat: Fix bad fast syscall arg failure path

Started byBorislav Petkov <bp@alien8.de>
First post2015-06-30 13:00 +0200
Last post2015-07-01 09:50 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v4 02/17] x86/entry/64/compat: Fix bad fast syscall arg  failure path Borislav Petkov <bp@alien8.de> - 2015-06-30 13:00 +0200
    Re: [PATCH v4 02/17] x86/entry/64/compat: Fix bad fast syscall arg  failure path Ingo Molnar <mingo@kernel.org> - 2015-06-30 13:10 +0200
    Re: [PATCH v4 02/17] x86/entry/64/compat: Fix bad fast syscall arg  failure path Ingo Molnar <mingo@kernel.org> - 2015-07-01 09:50 +0200

#1174439 — Re: [PATCH v4 02/17] x86/entry/64/compat: Fix bad fast syscall arg failure path

FromBorislav Petkov <bp@alien8.de>
Date2015-06-30 13:00 +0200
SubjectRe: [PATCH v4 02/17] x86/entry/64/compat: Fix bad fast syscall arg failure path
Message-ID<pH1qG-80t-15@gated-at.bofh.it>
On Mon, Jun 29, 2015 at 12:33:34PM -0700, Andy Lutomirski wrote:
> diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
> index bb187a6a877c..efe0b1e499fa 100644
> --- a/arch/x86/entry/entry_64_compat.S
> +++ b/arch/x86/entry/entry_64_compat.S
> @@ -425,8 +425,39 @@ cstar_tracesys:
>  END(entry_SYSCALL_compat)
>  
>  ia32_badarg:
> -	ASM_CLAC
> -	movq	$-EFAULT, RAX(%rsp)
> +	/*
> +	 * So far, we've entered kernel mode, set AC, turned on IRQs, and
> +	 * saved C regs except r8-r11.  We haven't done any of the other
> +	 * standard entry work, though.  We want to bail, but we shouldn't
> +	 * treat this as a syscall entry since we don't even know what the
> +	 * args are.  Instead, treat this as a non-syscall entry, finish
> +	 * the entry work, and immediately exit after setting AX = -EFAULT.
> +	 *
> +	 * We're really just being polite here.  Killing the task outright
> +	 * would be a reasonable action, too.  Given that the only valid
> +	 * way to have gotten here is through the vDSO, and we already know
> +	 * that the stack pointer is bad, the task isn't going to survive
> +	 * for long no matter what we do.

You mean something like

	force_sig_info(SIGSEGV, &si, current);

?

I'd say we do it and not noodle unnecessarily with zeroing out pt_regs
if the task is going to die anyway. IOW, make it die faster. :)

> +	 */
> +
> +	ASM_CLAC			/* undo STAC */
> +	movq	$-EFAULT, RAX(%rsp)	/* return -EFAULT if possible */
> +
> +	/* Fill in the rest of pt_regs */
> +	xorl	%eax, %eax
> +	movq	%rax, R11(%rsp)
> +	movq	%rax, R10(%rsp)
> +	movq	%rax, R9(%rsp)
> +	movq	%rax, R8(%rsp)
> +	SAVE_EXTRA_REGS
> +
> +	/* Turn IRQs back off. */
> +	DISABLE_INTERRUPTS(CLBR_NONE)
> +	TRACE_IRQS_OFF
> +
> +	/* And exit again. */
> +	jmp retint_user
> +
>  ia32_ret_from_sys_call:
>  	xorl	%eax, %eax		/* Do not leak kernel information */
>  	movq	%rax, R11(%rsp)
> -- 
> 2.4.3

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1174447

FromIngo Molnar <mingo@kernel.org>
Date2015-06-30 13:10 +0200
Message-ID<pH1Am-8qO-11@gated-at.bofh.it>
In reply to#1174439
* Borislav Petkov <bp@alien8.de> wrote:

> On Mon, Jun 29, 2015 at 12:33:34PM -0700, Andy Lutomirski wrote:
> > diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
> > index bb187a6a877c..efe0b1e499fa 100644
> > --- a/arch/x86/entry/entry_64_compat.S
> > +++ b/arch/x86/entry/entry_64_compat.S
> > @@ -425,8 +425,39 @@ cstar_tracesys:
> >  END(entry_SYSCALL_compat)
> >  
> >  ia32_badarg:
> > -	ASM_CLAC
> > -	movq	$-EFAULT, RAX(%rsp)
> > +	/*
> > +	 * So far, we've entered kernel mode, set AC, turned on IRQs, and
> > +	 * saved C regs except r8-r11.  We haven't done any of the other
> > +	 * standard entry work, though.  We want to bail, but we shouldn't
> > +	 * treat this as a syscall entry since we don't even know what the
> > +	 * args are.  Instead, treat this as a non-syscall entry, finish
> > +	 * the entry work, and immediately exit after setting AX = -EFAULT.
> > +	 *
> > +	 * We're really just being polite here.  Killing the task outright
> > +	 * would be a reasonable action, too.  Given that the only valid
> > +	 * way to have gotten here is through the vDSO, and we already know
> > +	 * that the stack pointer is bad, the task isn't going to survive
> > +	 * for long no matter what we do.
> 
> You mean something like
> 
> 	force_sig_info(SIGSEGV, &si, current);
> 
> ?

We should also emit a warning message, even if user-space installed a 'special' 
sigfault handler to hide such failures. (I'm looking at you systemd!)

Thanks,

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1175045

FromIngo Molnar <mingo@kernel.org>
Date2015-07-01 09:50 +0200
Message-ID<pHkWm-2ey-17@gated-at.bofh.it>
In reply to#1174439
* Andy Lutomirski <luto@amacapital.net> wrote:

> Given the current state of the asm, I think I'd rather get farther along in the 
> cleanups before trying to change behavior here.

Agreed.

Thanks,

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web