kernel-hardening.lists.openwall.com archive mirror
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Russell King - ARM Linux <linux@armlinux.org.uk>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arch <linux-arch@vger.kernel.org>,
	Kernel Hardening <kernel-hardening@lists.openwall.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	X86 ML <x86@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Alan Cox <alan@linux.intel.com>
Subject: [kernel-hardening] Re: [PATCH v4.1 02/10] asm/nospec, array_ptr: sanitize speculative array de-references
Date: Tue, 23 Jan 2018 10:17:49 +0000	[thread overview]
Message-ID: <20180123101748.GA2604@arm.com> (raw)
In-Reply-To: <CAPcyv4gjDrTnC_xeuVWjonvF7_L1Y-OOQndMRyVDdaLmcC7NMg@mail.gmail.com>

On Mon, Jan 22, 2018 at 10:52:54AM -0800, Dan Williams wrote:
> On Mon, Jan 22, 2018 at 10:37 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> > Note that 'idx' itself can have any range (that's kind of the _point_,
> > after all: checking that idx is in some range). But the logic only
> > works for a positive array size.
> >
> > Which honestly is not really a limitation, but it's worth spelling out, I think.

Agreed. We should be absolutely clear about when this thing works and when
it doesn't.

> > In particular, if you have a user pointer, and a 3G:1G split in
> > user:kernel address space, you camn *not* do something like
> >
> >     uptr = array_ptr(NULL, userptr, TASK_SIZE);
> >
> > to get a sanitized user pointer, because TASK_SIZE is not positive in 'long'.
> >
> > Hmm?
> 
> We could at least have a BUILD_BUG_ON when 'size' is a
> builtin_contstant and greater than LONG_MAX. Alternatively we could
> require archs to provide the equivalent of the x86 array_ptr_mask()
> that does not have the LONG_MAX limitation?

I'd rather avoid imposing that limitation and instead just treat uaccess
specially. It looks like we can satisfy the current definition of
array_ptr_mask with three instructions, but I'm not sure how we could get it
working on arm64 if we needed to deal with arbitrary sizes (particularly as
we're trying to avoid conditional instructions).

Will

  reply	other threads:[~2018-01-23 10:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-20 21:05 [kernel-hardening] [PATCH v4.1 00/10] spectre variant1 mitigations for tip/x86/pti Dan Williams
2018-01-20 21:06 ` [kernel-hardening] [PATCH v4.1 01/10] Documentation: document array_ptr Dan Williams
2018-01-22 19:00   ` Jann Horn
2018-01-20 21:06 ` [kernel-hardening] [PATCH v4.1 02/10] asm/nospec, array_ptr: sanitize speculative array de-references Dan Williams
2018-01-21 10:40   ` [kernel-hardening] " Russell King - ARM Linux
2018-01-21 15:07     ` Jann Horn
2018-01-21 20:15     ` Jann Horn
2018-01-21 20:24       ` Jann Horn
2018-01-22 18:07     ` Dan Williams
2018-01-22 18:37       ` Linus Torvalds
2018-01-22 18:52         ` Dan Williams
2018-01-23 10:17           ` Will Deacon [this message]
2018-01-20 21:06 ` [kernel-hardening] [PATCH v4.1 03/10] x86: implement array_ptr_mask() Dan Williams
2018-01-20 21:06 ` [kernel-hardening] [PATCH v4.1 04/10] x86: introduce __uaccess_begin_nospec and ifence Dan Williams
2018-01-20 21:06 ` [kernel-hardening] [PATCH v4.1 05/10] x86, __get_user: use __uaccess_begin_nospec Dan Williams
2018-01-20 21:06 ` [kernel-hardening] [PATCH v4.1 06/10] x86, get_user: use pointer masking to limit speculation Dan Williams
2018-01-20 21:06 ` [kernel-hardening] [PATCH v4.1 07/10] x86: narrow out of bounds syscalls to sys_read under speculation Dan Williams
2018-01-21 19:16   ` [kernel-hardening] " Andy Lutomirski
2018-01-21 19:25     ` Andy Lutomirski
2018-01-21 19:31     ` Jann Horn
2018-01-22  1:38       ` Andy Lutomirski
2018-01-22  2:04         ` Linus Torvalds
2018-01-22  2:23           ` Andy Lutomirski
2018-01-22 11:59           ` Samuel Neves
2018-01-20 21:06 ` [kernel-hardening] [PATCH v4.1 08/10] vfs, fdtable: prevent bounds-check bypass via speculative execution Dan Williams
2018-01-20 21:06 ` [kernel-hardening] [PATCH v4.1 09/10] kvm, x86: update spectre-v1 mitigation Dan Williams
2018-01-20 21:06 ` [kernel-hardening] [PATCH v4.1 10/10] nl80211: sanitize array index in parse_txq_params Dan Williams

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=20180123101748.GA2604@arm.com \
    --to=will.deacon@arm.com \
    --cc=alan@linux.intel.com \
    --cc=catalin.marinas@arm.com \
    --cc=dan.j.williams@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --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).