linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Jann Horn <jannh@google.com>, Kees Cook <keescook@chromium.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, kernel-hardening@lists.openwall.com,
	linux-kernel@vger.kernel.org, Andy Lutomirski <luto@kernel.org>,
	dvyukov@google.com
Subject: Re: [RFC PATCH 1/2] x86: WARN() when uaccess helpers fault on kernel addresses
Date: Tue, 7 Aug 2018 12:03:09 +0200	[thread overview]
Message-ID: <20180807100309.GB12200@gmail.com> (raw)
In-Reply-To: <C6369CAA-CBB8-420F-97DB-7A242D9650A8@amacapital.net>


* Andy Lutomirski <luto@amacapital.net> wrote:

> > On Aug 6, 2018, at 6:22 PM, Jann Horn <jannh@google.com> wrote:
> > 
> > There have been multiple kernel vulnerabilities that permitted userspace to
> > pass completely unchecked pointers through to userspace accessors:
> > 
> > - the waitid() bug - commit 96ca579a1ecc ("waitid(): Add missing
> >  access_ok() checks")
> > - the sg/bsg read/write APIs
> > - the infiniband read/write APIs
> > 
> > These don't happen all that often, but when they do happen, it is hard to
> > test for them properly; and it is probably also hard to discover them with
> > fuzzing. Even when an unmapped kernel address is supplied to such buggy
> > code, it just returns -EFAULT instead of doing a proper BUG() or at least
> > WARN().
> > 
> > This patch attempts to make such misbehaving code a bit more visible by
> > WARN()ing in the pagefault handler code when a userspace accessor causes
> > #PF on a kernel address and the current context isn't whitelisted.
> 
> I like this a lot, and, in fact, I once wrote a patch to do something similar. It was before 
> the fancy extable code, though, so it was a mess.  Here are some thoughts:

Agreed - please move this series beyond the RFC phase.

> - It should be three patches. One patch to add the _UA annotations, one to improve the info 
>   passes to the handlers, and one to change behavior.
>
> - You should pass the vector, the error code, and the address to the handler.
> 
> - The uaccess handler should IMO WARN if the vector is anything other than #PF (which mainly 
> means warning if it’s #GP). I think it should pr_emerg() and return false if the vector is 
> #PF and the address is too high.
> 
> - Arguably most non-uaccess fixups should at least warn for anything other than #GP and #UD.

Ack.

Thanks,

	Ingo

  reply	other threads:[~2018-08-07 10:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-07  1:22 [RFC PATCH 1/2] x86: WARN() when uaccess helpers fault on kernel addresses Jann Horn
2018-08-07  1:22 ` [RFC PATCH 2/2] lkdtm: test copy_to_user() on bad kernel pointer under KERNEL_DS Jann Horn
2018-08-07  2:36 ` [RFC PATCH 1/2] x86: WARN() when uaccess helpers fault on kernel addresses Kees Cook
2018-08-07  2:55 ` Andy Lutomirski
2018-08-07 10:03   ` Ingo Molnar [this message]
2018-08-07 21:17   ` Jann Horn
2018-08-07 22:28     ` Andy Lutomirski
2018-08-22 23:53   ` Jann Horn
2018-08-23  0:28     ` Andy Lutomirski
2018-08-23  0:55       ` Jann Horn
2018-08-23  1:36         ` Andy Lutomirski
2018-08-07 11:04 ` Dmitry Vyukov
2018-08-07 14:02   ` Andy Lutomirski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180807100309.GB12200@gmail.com \
    --to=mingo@kernel.org \
    --cc=dvyukov@google.com \
    --cc=hpa@zytor.com \
    --cc=jannh@google.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).