linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gens <david.gens@cs.tu-darmstadt.de>
To: Thomas Garnier <thgarnie@google.com>
Cc: Daniel Gruss <daniel.gruss@iaik.tugraz.at>,
	kernel list <linux-kernel@vger.kernel.org>,
	Kernel Hardening <kernel-hardening@lists.openwall.com>,
	clementine.maurice@iaik.tugraz.at, moritz.lipp@iaik.tugraz.at,
	Michael Schwarz <michael.schwarz@iaik.tugraz.at>,
	Richard Fellner <richard.fellner@student.tugraz.at>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Ingo Molnar <mingo@kernel.org>,
	anders.fogh@gdata-adan.de
Subject: Re: [kernel-hardening] [RFC, PATCH] x86_64: KAISER - do not map kernel in user mode
Date: Sat, 06 May 2017 06:02:29 +0200	[thread overview]
Message-ID: <01ebda5d918d9cbfd36d8ec4e6c12f55@cs.tu-darmstadt.de> (raw)
In-Reply-To: <CAJcbSZEOMssjUoMUBmArNeuOPoZ0gQJmEQ_WQaSOPiHp1XcNaQ@mail.gmail.com>

On 2017-05-05 17:47, Thomas Garnier wrote:
> On Fri, May 5, 2017 at 1:23 AM, Daniel Gruss
> <daniel.gruss@iaik.tugraz.at> wrote:
>> 
>> On 04.05.2017 17:28, Thomas Garnier wrote:
>>> 
>>> Please read the documentation on submitting patches [1] and coding 
>>> style [2].
>> 
>> 
>> I will have a closer look at that.
>> 
>>>  - How this approach prevent the hardware attacks you mentioned? You
>>> still have to keep a part of _text in the pagetable and an attacker
>>> could discover it no? (and deduce the kernel base address).
>> 
>> 
>> These parts are moved to a different section (.user_mapped) which is 
>> at a possibly predictable location - the location of the randomized 
>> parts of the kernel is independent of the location of .user_mapped.
>> The code/data footprint for .user_mapped is quite small, helping to 
>> reduce or eliminate the attack surface...
>> 
> 
> If I get it right, it means you can leak the per-cpu address instead
> of the kernel. Correct? That would be a problem because you can
> elevate privilege by overwriting per-cpu variables. Leaking this
> address means also defeating KASLR memory randomization [3] (cf paper
> in the commit).
> 
> In theory you could put the code in the fixmap but you still have the
> per-cpu variables and changing that is hard.
> 
> [3]
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=021182e52fe01c1f7b126f97fd6ba048dc4234fd

(Chiming in here, since we worked on something similar)

Assuming that their patch indeed leaks per-cpu addresses.. it might not 
necessarily
be required to change it. Since an adversary has to leak the per-cpu 
addresses
based on timing information you can work around that by inserting dummy 
entries
into the user mappings, with the goal of creating multiple candidate 
addresses
that show an identical measurement. For instance, you can create one 
entry for
every possible KASLR slot.


>>> You also need to make it clear that btb attacks are still possible.
>> 
>> 
>> By just increasing the KASLR randomization range, btb attacks can be 
>> mitigated (for free).
> 
> Correct, I hope we can do that.
> 
>> 
>>>  - What is the perf impact?
>> 
>> 
>> It will vary for different machines. We have promising results (<1%) 
>> for an i7-6700K with representative benchmarks. However, for older 
>> systems or for workloads with a lot of pressure on some TLB levels, 
>> the performance may be much worse.
> 
> I think including performance data in both cases would be useful.

Best,
David

  reply	other threads:[~2017-05-06  4:37 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-04 10:02 [RFC, PATCH] x86_64: KAISER - do not map kernel in user mode Daniel Gruss
2017-05-04 12:26 ` Daniel Gruss
2017-05-04 15:28 ` [kernel-hardening] " Thomas Garnier
2017-05-05  8:23   ` Daniel Gruss
2017-05-05 15:47     ` Thomas Garnier
2017-05-06  4:02       ` David Gens [this message]
2017-05-06  8:38         ` Daniel Gruss
2017-05-08 10:21           ` Mark Rutland
2017-05-08 10:51             ` Daniel Gruss
2017-05-08 13:22               ` Mark Rutland
2017-05-08 13:43                 ` Daniel Gruss
2017-05-08 13:53           ` Daniel Gruss
2017-05-08 14:09             ` Thomas Garnier
2017-05-08 14:19               ` Daniel Gruss
2017-05-08 13:23     ` Daniel Gruss
2017-05-04 15:47 ` Christoph Hellwig
2017-05-05  7:40   ` Daniel Gruss
2017-05-07 20:20     ` [kernel-hardening] " Richard Weinberger
2017-05-07 21:45       ` Daniel Gruss
2017-05-07 22:02         ` Richard Weinberger
2017-05-07 22:18           ` Daniel Gruss
2017-05-09 14:44             ` [kernel-hardening] Re: [RFC, PATCH] x86_64: KAISER - do not mapkernel " Fogh, Anders
2017-05-09 14:57               ` Richard Weinberger
2017-05-09 15:30                 ` Rik van Riel
2017-10-31 23:28                   ` Dave Hansen
2017-05-05 15:49 ` [kernel-hardening] [RFC, PATCH] x86_64: KAISER - do not map kernel " Jann Horn
2017-05-05 15:53   ` Jann Horn
2017-05-06  8:28     ` Daniel Gruss

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=01ebda5d918d9cbfd36d8ec4e6c12f55@cs.tu-darmstadt.de \
    --to=david.gens@cs.tu-darmstadt.de \
    --cc=anders.fogh@gdata-adan.de \
    --cc=clementine.maurice@iaik.tugraz.at \
    --cc=daniel.gruss@iaik.tugraz.at \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.schwarz@iaik.tugraz.at \
    --cc=mingo@kernel.org \
    --cc=moritz.lipp@iaik.tugraz.at \
    --cc=richard.fellner@student.tugraz.at \
    --cc=thgarnie@google.com \
    /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).