linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Avoid speculative indirect calls in kernel
@ 2018-01-03 23:09 Andi Kleen
  2018-01-03 23:09 ` [PATCH 01/11] x86/retpoline: Define retpoline indirect thunk and macros Andi Kleen
                   ` (11 more replies)
  0 siblings, 12 replies; 107+ messages in thread
From: Andi Kleen @ 2018-01-03 23:09 UTC (permalink / raw)
  To: tglx; +Cc: torvalds, gregkh, dwmw, tim.c.chen, linux-kernel, dave.hansen

This is a fix for Variant 2 in 
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

Any speculative indirect calls in the kernel can be tricked 
to execute any kernel code, which may allow side channel
attacks that can leak arbitrary kernel data.

So we want to avoid speculative indirect calls in the kernel.

There's a special code sequence called a retpoline that can
do indirect calls without speculation. We use a new compiler
option -mindirect-branch=thunk-extern (gcc patch will be released
separately) to recompile the kernel with this new sequence.

We also patch all the assembler code in the kernel to use
the new sequence.

The patches were originally from David Woodhouse and Tim Chen,
but then reworked and enhanced by me.

No performance numbers at this point. 32bit is only boot tested.

Git tree available in 
git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-misc spec/retpoline-415-1

v1: Initial post.

^ permalink raw reply	[flat|nested] 107+ messages in thread
* Avoid speculative indirect calls in kernel
@ 2018-01-04  2:00 Andi Kleen
  2018-01-04 11:49 ` Pavel Machek
  0 siblings, 1 reply; 107+ messages in thread
From: Andi Kleen @ 2018-01-04  2:00 UTC (permalink / raw)
  To: tglx; +Cc: torvalds, gregkh, linux-kernel, tim.c.chen

This is a fix for Variant 2 in 
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

Any speculative indirect calls in the kernel can be tricked 
to execute any kernel code, which may allow side channel
attacks that can leak arbitrary kernel data.

So we want to avoid speculative indirect calls in the kernel.

There's a special code sequence called a retpoline that can
do indirect calls without speculation. We use a new compiler
option -mindirect-branch=thunk-extern (gcc patch will be released
separately) to recompile the kernel with this new sequence.

We also patch all the assembler code in the kernel to use
the new sequence.

The patches were originally from David Woodhouse and Tim Chen,
but then reworked and enhanced by me.

No performance numbers at this point. 32bit is only boot tested.

Git tree available in 
git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-misc spec/retpoline-415-2

v1: Initial post.
v2:
Add CONFIG_RETPOLINE to build kernel without it.
Change warning messages.
Hide modpost warning message

^ permalink raw reply	[flat|nested] 107+ messages in thread
* Re: Avoid speculative indirect calls in kernel
@ 2018-01-12  8:20 Dr. Greg Wettstein
  0 siblings, 0 replies; 107+ messages in thread
From: Dr. Greg Wettstein @ 2018-01-12  8:20 UTC (permalink / raw)
  To: Alan Cox, Thomas Gleixner
  Cc: Jon Masters, Woodhouse, David, Paolo Bonzini, Linus Torvalds,
	Andi Kleen, Greg Kroah-Hartman, Tim Chen,
	Linux Kernel Mailing List, Dave Hansen, Jeff Law, Nick Clifton

On Jan 5, 12:12pm, Alan Cox wrote:
} Subject: Re: Avoid speculative indirect calls in kernel

Good morning to everyone, a bit behind on mail given everything which
has been going on.

> On Fri, 5 Jan 2018 01:54:13 +0100 (CET)
> Thomas Gleixner <tglx@linutronix.de> wrote:
> 
> > On Thu, 4 Jan 2018, Jon Masters wrote:
> > > P.S. I've an internal document where I've been tracking "nice to haves"
> > > for later, and one of them is whether it makes sense to tag binaries as
> > > "trusted" (e.g. extended attribute, label, whatever). It was something I
> > > wanted to bring up at some point as potentially worth considering.  
> > 
> > Scratch that. There is no such thing as a trusted binary.

> There is if you are using signing and the like. I'm sure SELinux and
> friends will grow the ability to set per process policy but that's
> certainly not a priority.
>
> However the question is wrong. 'trusted' is a binary operator not a
> unary one.

Alan's observations are correct.

In our autonomous introspection work we apply the notion that
'trusted' is a binary characteristic of a context of execution (COE).
Its value is an expression of whether or not the information exchange
events it has been involved in have deviated from the desired
execution trajectory path of the system.

It is a decidedly different way of thinking about things.  Most
importantly it is a namespaceable characteristic.

We have already written the futuristic LSM that Alan aludes to in
order to implement per COE security policies and forensics for
actors/COE's that have gone over to the 'dark side'.

> Alan

Have a good weekend.

Dr. Greg

}-- End of excerpt from Alan Cox

As always,
Dr. G.W. Wettstein, Ph.D.   Enjellic Systems Development, LLC.
4206 N. 19th Ave.           Specializing in information infra-structure
Fargo, ND  58102            development.
PH: 701-281-1686
FAX: 701-281-3949           EMAIL: greg@enjellic.com
------------------------------------------------------------------------------
"Given a choice between a complex, difficult-to-understand,
 disconcerting explanation and a simplistic, comforting one, many
 prefer simplistic comfort if it's remotely plausible, especially if it
 involves blaming someone else for their problems."
                                -- Bob Lewis
                                   _Infoworld_

^ permalink raw reply	[flat|nested] 107+ messages in thread
* Re: Avoid speculative indirect calls in kernel
@ 2018-02-23 21:10 Ywe Cærlyn
  0 siblings, 0 replies; 107+ messages in thread
From: Ywe Cærlyn @ 2018-02-23 21:10 UTC (permalink / raw)
  To: LKML

Patchmeister Torvalds:

"Or is Intel basically saying "we are committed to selling you shit
forever and ever, and never fixing anything"?"

Back in Celeron days, Intel was popular because you could clock the 
lesser cached Celeron 300mhz to ~500mhz.

Everybody knew then not to get anything pricier. But still Intel sells 
Xeons at 3x the price, for little noticable gain?

Basically I did research on philosophy, and indeed the mainconcept of a 
culture is what determines a cultures behaviour. Even the internal 
design of the cpu seems to be inspired by "God".

I have tried the zén-realized version "Zün", instead, God of absolute 
reality. Because regressions in philosophy, is regressions in computing, 
is ultimately Bill Gates talking about fecal water.

-- 
Fredelige hilsener,
Ywe Cærlyn,

^ permalink raw reply	[flat|nested] 107+ messages in thread

end of thread, other threads:[~2018-02-23 21:09 UTC | newest]

Thread overview: 107+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-03 23:09 Avoid speculative indirect calls in kernel Andi Kleen
2018-01-03 23:09 ` [PATCH 01/11] x86/retpoline: Define retpoline indirect thunk and macros Andi Kleen
2018-01-03 23:09 ` [PATCH 02/11] x86/retpoline/crypto: Convert crypto assembler indirect jumps Andi Kleen
2018-01-03 23:09 ` [PATCH 03/11] x86/retpoline/entry: Convert entry " Andi Kleen
2018-01-03 23:09 ` [PATCH 04/11] x86/retpoline/ftrace: Convert ftrace " Andi Kleen
2018-01-03 23:09 ` [PATCH 05/11] x86/retpoline/hyperv: Convert " Andi Kleen
2018-01-03 23:09 ` [PATCH 06/11] x86/retpoline/crypto: Convert xen " Andi Kleen
2018-01-03 23:09 ` [PATCH 07/11] x86/retpoline/checksum32: Convert " Andi Kleen
2018-01-03 23:09 ` [PATCH 08/11] x86/retpoline/irq32: " Andi Kleen
2018-01-03 23:09 ` [PATCH 09/11] x86/retpoline: Finally enable retpoline for C code Andi Kleen
2018-01-04  8:28   ` Greg KH
2018-01-04  8:30     ` Dave Hansen
2018-01-03 23:09 ` [PATCH 10/11] retpoline/taint: Taint kernel for missing retpoline in compiler Andi Kleen
2018-01-04  0:29   ` Thomas Gleixner
2018-01-04  0:35     ` Randy Dunlap
2018-01-03 23:09 ` [PATCH 11/11] retpoline/objtool: Disable some objtool warnings Andi Kleen
2018-01-03 23:51 ` Avoid speculative indirect calls in kernel Linus Torvalds
2018-01-04  0:00   ` Alan Cox
2018-01-04  0:09   ` Andi Kleen
2018-01-04  0:12     ` Thomas Gleixner
2018-01-04  0:15       ` Andi Kleen
2018-01-04  0:19         ` Jiri Kosina
2018-01-05  2:01           ` james harvey
2018-01-05 10:40             ` Woodhouse, David
2018-01-05 12:29               ` james harvey
2018-01-05 12:06             ` Alan Cox
2018-01-04  0:29         ` Alan Cox
2018-01-04  0:31           ` Thomas Gleixner
2018-01-04  0:38             ` Alan Cox
2018-01-04  0:40             ` Andi Kleen
2018-01-04  8:15               ` Woodhouse, David
2018-01-04 15:53                 ` Andi Kleen
2018-01-04 15:55                   ` Woodhouse, David
2018-01-04  0:20       ` Linus Torvalds
2018-01-04  0:26         ` Thomas Gleixner
2018-01-04  0:18     ` David Lang
2018-01-04  1:00   ` Paul Turner
2018-01-04  1:41   ` Paolo Bonzini
2018-01-04  1:59     ` Alan Cox
2018-01-04  2:11       ` Paolo Bonzini
2018-01-04  8:20         ` Woodhouse, David
2018-01-04 11:42           ` Pavel Machek
2018-01-04 11:47             ` Woodhouse, David
2018-01-04 14:20               ` Paolo Bonzini
2018-01-04 14:51                 ` Andrew Cooper
2018-01-04 15:29                   ` Woodhouse, David
2018-01-04 15:32                     ` Paolo Bonzini
2018-01-04 15:37                       ` Andrew Cooper
2018-01-04 16:15                     ` David Woodhouse
2018-01-04 20:00                       ` Tom Lendacky
2018-01-04 20:05                         ` David Woodhouse
2018-01-04 23:47                           ` Tom Lendacky
2018-01-05  0:06                             ` Andrew Cooper
2018-01-05  0:26                             ` Tom Lendacky
2018-01-04 16:52                     ` Andrea Arcangeli
2018-01-04 15:32                   ` Paolo Bonzini
2018-01-04 16:25                     ` Andrea Arcangeli
2018-01-04 17:04                       ` Alan Cox
2018-01-04 17:40                         ` Andrea Arcangeli
2018-01-04 17:13                       ` Dave Hansen
2018-01-04 17:15                         ` Paolo Bonzini
2018-01-04 18:05                           ` Andrea Arcangeli
2018-01-04 14:55                 ` Woodhouse, David
2018-01-04 18:24                 ` Pavel Machek
2018-01-04 19:57           ` Jon Masters
2018-01-05  0:41             ` Jon Masters
2018-01-05  0:54               ` Thomas Gleixner
2018-01-05  4:11                 ` Jon Masters
2018-01-05  9:59                   ` Thomas Gleixner
2018-01-08 10:28                     ` Andrea Arcangeli
2018-01-08 20:42                       ` [tip:x86/pti] x86/tboot: Unbreak tboot with PTI enabled tip-bot for Dave Hansen
2018-01-08 20:53                       ` Avoid speculative indirect calls in kernel Thomas Gleixner
2018-01-08 21:32                         ` Andrea Arcangeli
2018-01-10  0:45                           ` Thomas Gleixner
2018-01-10  1:11                             ` Dave Hansen
2018-01-10 16:02                               ` Thomas Gleixner
2018-01-05  6:49                 ` Willy Tarreau
2018-01-05  6:57                   ` Dave Hansen
2018-01-05  7:13                     ` Willy Tarreau
2018-01-07 14:14                       ` Borislav Petkov
2018-01-07 17:21                         ` David Lang
2018-01-07 18:49                           ` Borislav Petkov
2018-01-07 17:44                         ` Willy Tarreau
2018-01-07 18:55                           ` Borislav Petkov
2018-01-07 22:10                             ` Willy Tarreau
2018-01-08  9:18                               ` Thomas Gleixner
2018-01-08  9:29                                 ` Willy Tarreau
2018-01-08 16:22                               ` Borislav Petkov
2018-01-08 16:53                                 ` Willy Tarreau
2018-01-05 12:12                 ` Alan Cox
2018-01-09  1:44                   ` Samir Bellabes
     [not found]                 ` <CAL9bgJ8XNJgCtxR6+M+Vm9eDBVZ4Dyi_-Lt-Q1ei9N=TE2c6cg@mail.gmail.com>
2018-01-07  5:04                   ` Fwd: " Kiernan Hager
2018-01-07  6:39                     ` Willy Tarreau
2018-01-07 14:01                     ` Alan Cox
2018-01-07 17:47                       ` Willy Tarreau
2018-01-07 18:01                         ` Ivan Ivanov
2018-01-07 18:16                           ` Woodhouse, David
2018-01-04 11:26   ` Pavel Machek
2018-01-04 11:54     ` Alan Cox
2018-01-04 18:33     ` Linus Torvalds
2018-01-04 20:08       ` Jon Masters
  -- strict thread matches above, loose matches on Subject: below --
2018-01-04  2:00 Andi Kleen
2018-01-04 11:49 ` Pavel Machek
2018-01-04 12:09   ` Alan Cox
2018-01-04 13:32     ` Pavel Machek
2018-01-12  8:20 Dr. Greg Wettstein
2018-02-23 21:10 Ywe Cærlyn

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).