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


Groups > linux.kernel > #1406785

Re: [PATCH 5/7] x86/uaccess: Warn on uaccess faults other than #PF

From Borislav Petkov <bp@alien8.de>
Newsgroups linux.kernel
Subject Re: [PATCH 5/7] x86/uaccess: Warn on uaccess faults other than #PF
Date 2016-05-25 11:50 +0200
Message-ID <rCDBU-7Ok-31@gated-at.bofh.it> (permalink)
References <rCtjb-Ur-9@gated-at.bofh.it> <rCtjc-Ur-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, May 24, 2016 at 03:48:42PM -0700, Andy Lutomirski wrote:
> If a uaccess instruction fails due to an8 error other than #PF,
> warn.  If the fault is #GP, it most likely indicates access to a
> non-canonical address, which means that an access_ok check is
> missing, and that's bad.  If the fault is something else (#UD?),
> then something is very wrong and we should diagnose it rather
> than ignoring it.
> 
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
>  arch/x86/mm/extable.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
> index 658292fdee5e..c1933471fce7 100644
> --- a/arch/x86/mm/extable.c
> +++ b/arch/x86/mm/extable.c
> @@ -29,6 +29,19 @@ EXPORT_SYMBOL(ex_handler_default);
>  static bool uaccess_fault_okay(int trapnr, unsigned long error_code,
>  			       unsigned long extra)
>  {
> +	/*
> +	 * For uaccess, only page faults should be fixed up.  I can't see
> +	 * any exploit mitigation value in OOPSing on other types of faults,
> +	 * so just warn and continue if that happens.  This means that
> +	 * uaccess faults to non-canonical addresses will warn.  That's okay
> +	 * -- this will only happen if an access_ok is missing, and we want to
> +	 * detect that error if it happens.
> +	 */
> +	if (WARN_ONCE(trapnr != X86_TRAP_PF,
> +		      "unexpected uaccess trap %d (may indicate a missing access_ok on a non-canonical address)\n",
> +		      trapnr))

Perhaps dump also regs->ip and make the warn message more helpful...

> +		return true;  /* no good reason to OOPS. */

You love those side comments, don'tcha? :-)

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/7] x86: uaccess hardening, easy part Andy Lutomirski <luto@kernel.org> - 2016-05-25 00:50 +0200
  [PATCH 5/7] x86/uaccess: Warn on uaccess faults other than #PF Andy Lutomirski <luto@kernel.org> - 2016-05-25 00:50 +0200
    Re: [PATCH 5/7] x86/uaccess: Warn on uaccess faults other than #PF Borislav Petkov <bp@alien8.de> - 2016-05-25 11:50 +0200
      Re: [PATCH 5/7] x86/uaccess: Warn on uaccess faults other than #PF Andy Lutomirski <luto@amacapital.net> - 2016-05-29 18:50 +0200
  [PATCH 1/7] x86/xen: Simplify set_aliased_prot Andy Lutomirski <luto@kernel.org> - 2016-05-25 01:00 +0200
    Re: [PATCH 1/7] x86/xen: Simplify set_aliased_prot Andrew Cooper <andrew.cooper3@citrix.com> - 2016-05-25 11:40 +0200
    Re: [Xen-devel] [PATCH 1/7] x86/xen: Simplify set_aliased_prot David Vrabel <david.vrabel@citrix.com> - 2016-05-25 12:00 +0200
  [PATCH 3/7] x86/uaccess: Give uaccess faults their own handler Andy Lutomirski <luto@kernel.org> - 2016-05-25 01:00 +0200
  [PATCH 2/7] x86/extable: Pass error_code and an extra unsigned long to exhandlers Andy Lutomirski <luto@kernel.org> - 2016-05-25 01:00 +0200
  Re: [PATCH 0/7] x86: uaccess hardening, easy part Brian Gerst <brgerst@gmail.com> - 2016-05-25 06:00 +0200
    Re: [PATCH 0/7] x86: uaccess hardening, easy part Kees Cook <keescook@chromium.org> - 2016-05-25 19:20 +0200
  Re: [PATCH 0/7] x86: uaccess hardening, easy part Kees Cook <keescook@chromium.org> - 2016-05-25 19:40 +0200

csiph-web