linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Arcangeli <aarcange@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Alan Cox <gnomes@lxorguk.ukuu.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-arch@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Netdev <netdev@vger.kernel.org>, Ingo Molnar <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 06/18] x86, barrier: stop speculation for failed access_ok
Date: Mon, 8 Jan 2018 11:02:51 +0100	[thread overview]
Message-ID: <20180108100251.GJ25546@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1801062038510.2376@nanos>

On Sat, Jan 06, 2018 at 08:41:34PM +0100, Thomas Gleixner wrote:
> optimized argumentation. We need to make sure that we have a solution which
> kills the problem safely and then take it from there. Correctness first,
> optimization later is the rule for this. Better safe than sorry.

Agreed, assuming the objective here is to achieve a complete spectre
fix fast.

Also note there's a whole set of stuff to do in addition of IBRS:
IBPB, stuff_RSB() and the register hygiene in kernel entry points and
vmexists, that alters the whole syscall stackframe to be able to clear
callee saved registers.

That register hygiene was one of the most tedious pieces to get right
along with the PTI "rep movsb" (no C) stack trampoline that never
calls into C code with zero stack available because it's very bad to
do so, consdering C is free to use some stack for register spillage.

I suggest to discuss how important register hygiene is on top of IBRS,
IBPB and stuff_RSB() to fix spectre, not future optimizations that
only matter for old CPUS and are irrelevant for future silicon.

I also suggest to discuss how to automate the other parts of variant#1
lfence/mfence across the bound checks, depending on arch with a open
source scanner, or if to pretend developers think about it like we
think about mb() (except no regression test will ever notice a bounds
check speculation memory barrier missing).

Reptolines alone are leaving a whole set of stuff unfixed: register
hygiene still missing, bios/firmware calls still require ibrs, all asm
has to be audited by hand as there's no sure asm scanner I know of
(grep can go somewhere though) and the gcc dependency isn't very
flexible to begin with, and they don't help with lfence/mfence across
bound checks, they still require IBPB and stuff_RSB() to avoid
guest/user mode against guest/user spectre variant#2 attacks.

I don't see why we should talk about pure performance optimization at
this point instead of focusing on the above.

Not to tell if you want to guarantee mathematically that guest
userland cannot read the guest kernel memory by starting a spectre
variant#2 attack from guest userland to host userland (David Gilbert's
new attack discovery). For that you'll have to set ibrs_enabled 2
ibpb_enabled 1 mode or ibrs_enabled 0 ibpb_enabled 2 mode in the host
kernel or alternatively ibrs_enabled 0 ibpb_enabled 2 in the guest
kernel.

ibrs 2 bpbp 1 will prevent qemu userland to use the IBP so guest
userland cannot probe it. ibrs 0 ibpb 2 will flush the IBP state at
vmexit so qemu userland won't be affected by it. ibrs 0 ibpb 2 in
guest will flush the IBP state at kernel entry so guest userland won't
be able to affect anything.

Of course such an attack from guest user -> guest kernel -> host
kernel -> host user -> host kernel -> guest kernel -> guest user and
probing IBP (RSB is fixed for good with unconditional stuff_RSB in
vmexit even when SMEP is set, precisely because SMEP won't stop guest
ring 3 to probe host ring 3 RSB and same for ring 0) is far fetched,
but reptolines alone cannot solve it unless you also build qemu
userland with reptolines (which then means the whole userland has to
be built with reptolines because the qemu dependency chain is endless,
includes glibc etc..).

As a reminder (for lkml): if you use KVM, spectre variant#2 is the
only attack that can affect guest/host memory isolation. spectre
variant#1 and meltdown (aka variant#3) always have been impossible
through KVM guest/user isolation. spectre variant#2 is the one that is
harder to fix and it's the most theoretical of them all and it may be
impossible to mount as an attack depending on host kernel code that
has to play against itself to achieve it. The setup for such an attack
is very tedious, takes half an hour or several hours depending on the
amounts of memory and you may have to know already accurately the
kernel that is running on the host. As opposed to spectre variant#1
and meltdown (aka variant#3), it's very unlikely anybody gets attacked
through spectre variant#2. It's also the side channel with the lowest
amount of kbytes/sec of bandwidth if mounted successfully in the first
place. However if it can be mounted successfully it becomes almost a
concern as the other two variants, which is why it needs fixing too.

Thanks,
Andrea

  parent reply	other threads:[~2018-01-08 10:02 UTC|newest]

Thread overview: 258+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-06  1:09 [PATCH 00/18] prevent bounds-check bypass via speculative execution Dan Williams
2018-01-06  1:09 ` Dan Williams
2018-01-06  1:09 ` [PATCH 01/18] asm-generic/barrier: add generic nospec helpers Dan Williams
2018-01-06  1:09   ` Dan Williams
2018-01-06  2:55   ` Linus Torvalds
2018-01-06  5:23     ` Dan Williams
2018-01-06  5:23       ` Dan Williams
2018-01-06 17:08       ` Mark Rutland
2018-01-06  1:10 ` [PATCH 02/18] Documentation: document " Dan Williams
2018-01-06  1:10   ` Dan Williams
2018-01-08 16:29   ` Jonathan Corbet
2018-01-08 16:29     ` Jonathan Corbet
2018-01-08 17:09     ` Mark Rutland
2018-01-08 17:09       ` Mark Rutland
2018-01-08 21:19       ` Jonathan Corbet
2018-01-08 21:19         ` Jonathan Corbet
2018-01-06  1:10 ` [PATCH 03/18] arm64: implement nospec_ptr() Dan Williams
2018-01-06  1:10   ` Dan Williams
2018-01-06  1:10 ` [PATCH 04/18] arm: " Dan Williams
2018-01-06  1:10   ` Dan Williams
2018-01-10  2:04   ` Laura Abbott
2018-01-10  7:40     ` Hanjun Guo
2018-01-10  7:40       ` Hanjun Guo
2018-01-10 17:24       ` Laura Abbott
2018-01-06  1:10 ` [PATCH 05/18] x86: implement nospec_barrier() Dan Williams
2018-01-06  1:10 ` [PATCH 06/18] x86, barrier: stop speculation for failed access_ok Dan Williams
2018-01-06  1:10   ` Dan Williams
2018-01-06  2:52   ` Linus Torvalds
2018-01-06  3:09     ` Linus Torvalds
2018-01-06  3:09       ` Linus Torvalds
2018-01-06 23:31       ` Dan Williams
2018-01-06 23:31         ` Dan Williams
2018-01-07  1:20         ` Linus Torvalds
2018-01-07  1:20           ` Linus Torvalds
2018-01-08 21:09           ` Dan Williams
2018-01-08 21:09             ` Dan Williams
2018-01-08 23:44             ` Linus Torvalds
2018-01-08 23:53               ` Dan Williams
2018-01-06  5:47     ` Dan Williams
2018-01-06 12:32     ` Alan Cox
2018-01-06 17:56       ` Linus Torvalds
2018-01-06 17:56         ` Linus Torvalds
2018-01-06 18:13       ` Alexei Starovoitov
2018-01-06 18:29         ` Dan Williams
2018-01-06 18:29           ` Dan Williams
2018-01-06 18:39           ` Alexei Starovoitov
2018-01-06 18:39             ` Alexei Starovoitov
2018-01-06 18:54             ` Dan Williams
2018-01-06 18:54               ` Dan Williams
2018-01-06 19:25               ` Alexei Starovoitov
2018-01-06 19:36                 ` Dan Williams
2018-01-06 19:36                   ` Dan Williams
2018-01-06 19:41                 ` Thomas Gleixner
2018-01-06 19:41                   ` Thomas Gleixner
2018-01-08 10:02                   ` Andrea Arcangeli [this message]
2018-01-08 10:02                     ` Andrea Arcangeli
2018-01-06 18:38         ` Alan Cox
2018-01-06 18:51           ` Alexei Starovoitov
2018-01-06 18:51             ` Alexei Starovoitov
2018-01-06 19:55             ` Alan Cox
2018-01-06 20:09               ` Alexei Starovoitov
2018-01-06 20:09                 ` Alexei Starovoitov
2018-01-06 20:22                 ` Alan Cox
2018-01-06 20:22                   ` Alan Cox
2018-01-06 21:17                   ` Alexei Starovoitov
2018-01-06 21:21                     ` Thomas Gleixner
2018-01-06 23:05                     ` Alan Cox
2018-01-06 23:05                       ` Alan Cox
2018-01-07  3:38                       ` Alexei Starovoitov
2018-01-07  6:33                         ` Willy Tarreau
2018-01-07  6:33                           ` Willy Tarreau
2018-01-07 19:47                           ` Linus Torvalds
2018-01-07 20:12                             ` Willy Tarreau
2018-01-07 20:17                               ` Linus Torvalds
2018-01-07 20:17                                 ` Linus Torvalds
2018-01-07 20:56                                 ` Thomas Gleixner
2018-01-08  2:23                                   ` David Miller
2018-01-08  2:23                                     ` David Miller
2018-01-08  7:38                                     ` Greg KH
2018-01-08  7:38                                       ` Greg KH
2018-01-07 22:15                                 ` Willy Tarreau
2018-01-07 22:15                                   ` Willy Tarreau
2018-01-07 20:15                             ` Dan Williams
2018-01-08  2:24                               ` Alexei Starovoitov
2018-01-08  2:24                                 ` Alexei Starovoitov
2018-01-08  9:51                                 ` Peter Zijlstra
2018-01-08 18:21                                   ` Ingo Molnar
2018-01-08 12:00                             ` David Laight
2018-01-08 12:12                               ` Alan Cox
2018-01-08 12:33                                 ` David Laight
2018-01-07 10:08                         ` Thomas Gleixner
2018-01-08  2:09                           ` Alexei Starovoitov
2018-01-07 13:59                         ` Alan Cox
2018-01-08  2:57                           ` Alexei Starovoitov
2018-01-08  2:57                             ` Alexei Starovoitov
2018-01-08  9:57                             ` Peter Zijlstra
2018-01-08  9:57                               ` Peter Zijlstra
2018-01-06 20:42           ` Willy Tarreau
2018-01-07  1:36             ` David Miller
2018-01-07  1:36               ` David Miller
2018-01-07 17:19               ` James Bottomley
2018-01-07 17:19                 ` James Bottomley
2018-01-07 18:31                 ` Thomas Gleixner
2018-01-07 18:31                   ` Thomas Gleixner
2018-01-08  2:04                   ` David Miller
2018-01-07 19:24                 ` Alan Cox
2018-01-09 21:41     ` Josh Poimboeuf
2018-01-09 21:41       ` Josh Poimboeuf
2018-01-09 21:47       ` Dan Williams
2018-01-09 21:47         ` Dan Williams
2018-01-09 21:49         ` Josh Poimboeuf
2018-01-09 21:49           ` Josh Poimboeuf
2018-01-09 21:59           ` Dan Williams
2018-01-09 21:59             ` Dan Williams
2018-01-09 22:23             ` Josh Poimboeuf
2018-01-09 22:35               ` Dan Williams
2018-01-09 22:35                 ` Dan Williams
2018-01-06  1:10 ` [PATCH 07/18] [media] uvcvideo: prevent bounds-check bypass via speculative execution Dan Williams
2018-01-06  1:10   ` Dan Williams
2018-01-06  9:09   ` Greg KH
2018-01-06  9:09     ` Greg KH
2018-01-06  9:40     ` Greg KH
2018-01-06 17:41       ` Dan Williams
2018-01-06 17:41         ` Dan Williams
2018-01-07  9:09         ` Greg KH
2018-01-07  9:09           ` Greg KH
2018-01-07 19:37           ` Dan Williams
2018-01-07 19:37             ` Dan Williams
2018-01-09  8:40       ` Laurent Pinchart
2018-01-09 10:04         ` Greg KH
2018-01-09 10:04           ` Greg KH
2018-01-09 14:26           ` Laurent Pinchart
2018-01-09 14:26             ` Laurent Pinchart
2018-01-09 14:47             ` Greg KH
2018-01-09 14:47               ` Greg KH
2018-01-08 11:23   ` Laurent Pinchart
2018-01-08 11:23     ` Laurent Pinchart
2018-01-09  2:11     ` Dan Williams
2018-01-06  1:10 ` [PATCH 08/18] carl9170: " Dan Williams
2018-01-06  1:10   ` Dan Williams
2018-01-06 10:01   ` Sergei Shtylyov
2018-01-06 14:23   ` Christian Lamparter
2018-01-06 15:06     ` Alan Cox
2018-01-06 15:06       ` Alan Cox
2018-01-06 16:38       ` Christian Lamparter
2018-01-06 16:34     ` Dan Williams
2018-01-06 16:34       ` Dan Williams
2018-01-06  1:10 ` [PATCH 09/18] p54: " Dan Williams
2018-01-06  1:10   ` Dan Williams
2018-01-06 10:01   ` Sergei Shtylyov
2018-01-06 10:01     ` Sergei Shtylyov
2018-01-06  1:10 ` [PATCH 10/18] qla2xxx: " Dan Williams
2018-01-06  1:10   ` Dan Williams
2018-01-06  9:03   ` Greg KH
2018-01-06  9:03     ` Greg KH
2018-01-06  9:42     ` Greg KH
2018-01-11 22:15     ` Dan Williams
2018-01-12  7:27       ` Greg KH
2018-01-12 15:25         ` James Bottomley
2018-01-06  1:10 ` [PATCH 11/18] cw1200: " Dan Williams
2018-01-06  1:10   ` Dan Williams
2018-01-06  1:10 ` [PATCH 12/18] Thermal/int340x: " Dan Williams
2018-01-06  1:10   ` Dan Williams
2018-01-06  1:53   ` Srinivas Pandruvada
2018-01-06  1:57     ` Dan Williams
2018-01-06 17:24       ` Srinivas Pandruvada
2018-01-06 17:24         ` Srinivas Pandruvada
2018-01-06 10:03   ` Sergei Shtylyov
2018-01-06 10:03     ` Sergei Shtylyov
2018-01-06  1:11 ` [PATCH 13/18] ipv6: " Dan Williams
2018-01-06  1:11   ` Dan Williams
2018-01-06 10:04   ` Sergei Shtylyov
2018-01-06 10:04     ` Sergei Shtylyov
2018-01-06 14:48   ` Stephen Hemminger
2018-01-06 18:05     ` Dan Williams
2018-01-06  1:11 ` [PATCH 14/18] ipv4: " Dan Williams
2018-01-06  9:00   ` Greg KH
2018-01-06  9:01   ` Greg KH
2018-01-06  9:01     ` Greg KH
2018-01-06 12:23     ` Alan Cox
2018-01-06 15:14       ` Greg KH
2018-01-06 15:14         ` Greg KH
2018-01-06 16:29         ` Dan Williams
2018-01-06 16:29           ` Dan Williams
2018-01-06 18:10           ` Dan Williams
2018-01-06 18:10             ` Dan Williams
2018-01-06 10:04   ` Sergei Shtylyov
2018-01-06  1:11 ` [PATCH 15/18] vfs, fdtable: " Dan Williams
2018-01-06  1:11   ` Dan Williams
2018-01-06 10:05   ` Sergei Shtylyov
2018-01-06  1:11 ` [PATCH 16/18] net: mpls: " Dan Williams
2018-01-06  1:11   ` Dan Williams
2018-01-06 10:06   ` Sergei Shtylyov
2018-01-06 10:06     ` Sergei Shtylyov
2018-01-09  3:11   ` Eric W. Biederman
2018-01-09  3:42     ` Dan Williams
2018-01-09  3:42       ` Dan Williams
2018-01-09  4:13       ` Linus Torvalds
2018-01-09  4:13         ` Linus Torvalds
2018-01-09  4:21         ` Linus Torvalds
2018-01-10  0:48         ` Dan Williams
2018-01-10  0:48           ` Dan Williams
2018-01-10  1:33           ` Dan Williams
2018-01-10  1:33             ` Dan Williams
2018-01-10  1:57           ` Alexei Starovoitov
2018-01-10  1:57             ` Alexei Starovoitov
2018-01-10  2:22             ` Dan Williams
2018-01-10  2:22               ` Dan Williams
2018-01-10  3:07               ` Alexei Starovoitov
2018-01-10  3:27           ` Linus Torvalds
2018-01-10  3:27             ` Linus Torvalds
2018-01-09 16:17       ` Eric W. Biederman
2018-01-09 16:17         ` Eric W. Biederman
2018-01-09 18:01         ` Dan Williams
2018-01-10  0:54           ` Eric W. Biederman
2018-01-10  0:54             ` Eric W. Biederman
2018-01-10  1:31             ` Dan Williams
2018-01-06  1:11 ` [PATCH 17/18] udf: " Dan Williams
2018-01-06  1:11   ` Dan Williams
2018-01-08 10:20   ` Jan Kara
2018-01-06  1:11 ` [PATCH 18/18] userns: " Dan Williams
2018-01-06  1:11   ` Dan Williams
2018-01-06  2:22 ` [PATCH 00/18] " Eric W. Biederman
2018-01-06  2:22   ` Eric W. Biederman
     [not found]   ` <87y3lbpvzp.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2018-01-06  6:30     ` Dan Williams
2018-01-06  6:30       ` Dan Williams
2018-01-08 10:08       ` Peter Zijlstra
2018-01-08 10:08         ` Peter Zijlstra
2018-01-08 11:43         ` Alan Cox
2018-01-08 11:43           ` Alan Cox
2018-01-08 11:55           ` Peter Zijlstra
2018-01-08 11:55             ` Peter Zijlstra
2018-01-08 18:33           ` Ingo Molnar
2018-01-08 18:33             ` Ingo Molnar
2018-01-08 16:20       ` Bart Van Assche
2018-01-08 16:20         ` Bart Van Assche
2018-01-06 18:56 ` Florian Fainelli
2018-01-06 18:56   ` Florian Fainelli
2018-01-06 18:59   ` Arjan van de Ven
2018-01-06 18:59     ` Arjan van de Ven
2018-01-06 19:37 ` Dan Williams
2018-01-06 19:37   ` Dan Williams
2018-01-06 20:07   ` Dan Williams
2018-01-06 20:07     ` Dan Williams
2018-01-09 19:34 ` Jiri Kosina
2018-01-09 19:34   ` Jiri Kosina
2018-01-09 19:44   ` Dan Williams
2018-01-09 19:44     ` Dan Williams
2018-01-09 20:55     ` Josh Poimboeuf
2018-01-09 20:55       ` Josh Poimboeuf
2018-01-11  9:54       ` Jiri Kosina
2018-01-11  9:54         ` Jiri Kosina
2018-01-11 15:58         ` Dan Williams
2018-01-11 15:58           ` Dan Williams
2018-01-11 16:34           ` Daniel Borkmann
2018-01-11 16:34             ` Daniel Borkmann
  -- strict thread matches above, loose matches on Subject: below --
2018-01-09  0:12 [PATCH 06/18] x86, barrier: stop speculation for failed access_ok Linus Torvalds
2018-01-09  0:12 ` Linus Torvalds

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=20180108100251.GJ25546@redhat.com \
    --to=aarcange@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=arnd@arndb.de \
    --cc=dan.j.williams@intel.com \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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).