linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: Thomas Garnier <thgarnie@google.com>
Cc: Andy Lutomirski <luto@kernel.org>,
	Arjan van de Ven <arjan@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>,
	Kees Cook <keescook@chromium.org>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave@sr71.net>, Chen Yucong <slaoub@gmail.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Anna-Maria Gleixner <anna-maria@linutronix.de>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Juergen Gross <jgross@suse.com>,
	Richard Weinberger <richard@nod.at>, X86 ML <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel-hardening@lists.openwall.com" 
	<kernel-hardening@lists.openwall.com>
Subject: Re: [RFC] x86/mm/KASLR: Remap GDTs at fixed location
Date: Thu, 5 Jan 2017 13:19:46 -0800	[thread overview]
Message-ID: <CALCETrUpC-Zp-mHCMVE6QdXTnzJDQLyckqaZhW0KJfZeX=oxXg@mail.gmail.com> (raw)
In-Reply-To: <CAJcbSZHAtxbRzhTcZtBSabW0t+Cj7a1z-xJk8d310a2h8pkG=g@mail.gmail.com>

On Thu, Jan 5, 2017 at 1:08 PM, Thomas Garnier <thgarnie@google.com> wrote:
> On Thu, Jan 5, 2017 at 12:18 PM, Andy Lutomirski <luto@kernel.org> wrote:
>> On Thu, Jan 5, 2017 at 11:03 AM, Thomas Garnier <thgarnie@google.com> wrote:
>>> On Thu, Jan 5, 2017 at 10:58 AM, Arjan van de Ven <arjan@linux.intel.com> wrote:
>>>> On 1/5/2017 9:54 AM, Thomas Garnier wrote:
>>>>
>>>>>
>>>>> That's my goal too. I started by doing a RO remap and got couple
>>>>> problems with hibernation. I can try again for the next iteration or
>>>>> delay it for another patch. I also need to look at KVM GDT usage, I am
>>>>> not familiar with it yet.
>>>>
>>>>
>>>> don't we write to the GDT as part of the TLS segment stuff for glibc ?
>>>>
>>>
>>> Not sure which glibc feature it is.
>>>
>>> In this design, you can write to the GDT per-cpu variable that will
>>> remain read-write. You just need to make the remapping writeable when
>>> we load task registers (ltr) then the processor use the current GDT
>>> address. At least that the case I know, I might find more through
>>> testing.
>>
>> Hmm.  I bet that if we preset the accessed bits in all the segments
>> then we don't need it to be writable in general.  But your point about
>> set_thread_area (TLS) is well taken.  However, I strongly suspect that
>> we could make set_thread_area unconditionally set the accessed bit and
>> no one would ever notice.
>
> Not sure I fully understood and I don't want to miss an important
> point. Do you mean making GDT (remapping and per-cpu) read-only and
> switch the writeable flag only when we write to the per-cpu entry?
>

What I mean is: write to the GDT through normal percpu access (or
whatever the normal mapping is) but load a read-only alias into the
GDT register.  As long as nothing ever tries to write through the GDTR
alias, no page faults will be generated.  So we just need to make sure
that nothing ever writes to it through GDTR.  AFAIK the only reason
the CPU ever writes to the address in GDTR is to set an accessed bit.

--Andy

  reply	other threads:[~2017-01-05 21:20 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-04 22:16 [RFC] x86/mm/KASLR: Remap GDTs at fixed location Thomas Garnier
2017-01-05  8:11 ` Ingo Molnar
2017-01-05 15:08   ` Arjan van de Ven
2017-01-05 16:40     ` Thomas Garnier
2017-01-05 18:56       ` Arjan van de Ven
2017-01-05 19:00         ` Thomas Garnier
2017-01-06 17:44       ` Borislav Petkov
2017-01-06 18:04         ` Thomas Garnier
2017-01-05 16:39   ` Thomas Garnier
2017-01-06  6:34     ` Ingo Molnar
2017-01-05 17:51 ` Andy Lutomirski
2017-01-05 17:54   ` Thomas Garnier
2017-01-05 18:01     ` Andy Lutomirski
2017-01-05 18:35       ` Thomas Garnier
2017-01-05 18:58     ` Arjan van de Ven
2017-01-05 19:03       ` Thomas Garnier
2017-01-05 20:18         ` Andy Lutomirski
2017-01-05 21:08           ` Thomas Garnier
2017-01-05 21:19             ` Andy Lutomirski [this message]
2017-01-05 21:58               ` Thomas Garnier
2017-01-06  6:49                 ` Ingo Molnar
2017-01-06 18:03                   ` Thomas Garnier
2017-01-06 21:59                     ` Andy Lutomirski
2017-01-06 22:54                       ` Thomas Garnier
2017-01-06 23:39                         ` Andy Lutomirski
2017-01-07  7:45                           ` Ingo Molnar
2017-01-07 15:58                             ` Andy Lutomirski
2017-01-07  7:35                         ` Ingo Molnar
2017-01-07 16:02                           ` Andy Lutomirski
2017-01-09 22:32                           ` Thomas Garnier
2017-01-10 10:27                             ` Ingo Molnar
2017-01-10 17:13                               ` Thomas Garnier
2017-01-05 23:05           ` Linus Torvalds
2017-01-05 23:16             ` Thomas Garnier
2017-01-06  2:34             ` Andy Lutomirski
2017-01-06 18:02               ` Thomas Garnier
2017-01-06 21:53                 ` Andy Lutomirski
2017-01-07  7:46                   ` Ingo Molnar
2017-01-06  6:45       ` Ingo Molnar

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='CALCETrUpC-Zp-mHCMVE6QdXTnzJDQLyckqaZhW0KJfZeX=oxXg@mail.gmail.com' \
    --to=luto@amacapital.net \
    --cc=akpm@linux-foundation.org \
    --cc=anna-maria@linutronix.de \
    --cc=arjan@linux.intel.com \
    --cc=bigeasy@linutronix.de \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=dave@sr71.net \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=paul.gortmaker@windriver.com \
    --cc=richard@nod.at \
    --cc=slaoub@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=thgarnie@google.com \
    --cc=x86@kernel.org \
    --cc=yamada.masahiro@socionext.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).