linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] [v2] x86/mm/pti: close two Meltdown leaks with Global kernel mapping
@ 2018-08-02 22:58 Dave Hansen
  2018-08-02 22:58 ` [PATCH 1/7] x86/mm/pti: clear Global bit more aggressively Dave Hansen
                   ` (6 more replies)
  0 siblings, 7 replies; 23+ messages in thread
From: Dave Hansen @ 2018-08-02 22:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dave Hansen, keescook, tglx, mingo, aarcange, jgross, jpoimboe,
	gregkh, peterz, hughd, torvalds, bp, luto, ak


The fixes for the problem Hugh reported took a bit more surgery
than I would have liked, but they do appear to work.  Note that
the last two patches are unnecessary cleanups that could be removed
from backports.

Changes from v1:
 * Modify set_memory_np() to avoid messing with the direct map
   by limiting its changes to the high kernel image map.

--

This applies to 4.17 and 4.18.

Thanks to Hugh Dickins for initially finding the r/w kernel text
issue and coming up with an initial fix.  I found the "unused
hole" part and came up with different approach for fixing the
mess.

--

Background:

Process Context IDentifiers (PCIDs) are a hardware feature that
allows TLB entries to survive page table switches (CR3 writes).
As an optimization, the PTI code currently allows the kernel image
to be Global when running on hardware without PCIDs.  This results
in fewer TLB misses, especially upon entry.

The downside is that these Global areas are theoretically
susceptible to Meltdown.  The logic is that there are no secrets
in the kernel image, so why pay the cost of TLB misses.

Problem:

The current PTI code leaves the entire area of the kernel binary
between '_text' and '_end' as Global (on non-PCID hardware).
However, that range contains both read-write kernel data, and two
"unused" holes in addition to text.  The areas which are not text
or read-only might contain secrets once they are freed back into
the allocator.

This issue affects systems which are susceptible to Meltdown, do not
have PCIDs and which are using the default PTI_AUTO mode (no
pti=on/off on the cmdline).

PCIDs became generally available for servers in ~2010 (Westmere)
and desktop (client) parts in roughly 2011 (Sandybridge).  This
is not expected to affect anything newer than that.

Solution:

The solution for the read-write area is to clear the global bit
for the area (patch #1).

The "unused" holes need a bit more work since we free them in a
bit of an ad-hoc way, but we fix this up in patches 2-5.

Cc: Kees Cook <keescook@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>

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

end of thread, other threads:[~2018-08-06 20:23 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-02 22:58 [PATCH 0/7] [v2] x86/mm/pti: close two Meltdown leaks with Global kernel mapping Dave Hansen
2018-08-02 22:58 ` [PATCH 1/7] x86/mm/pti: clear Global bit more aggressively Dave Hansen
2018-08-05 20:30   ` [tip:x86/pti] x86/mm/pti: Clear " tip-bot for Dave Hansen
2018-08-02 22:58 ` [PATCH 2/7] mm: allow non-direct-map arguments to free_reserved_area() Dave Hansen
2018-08-05 20:31   ` [tip:x86/pti] mm: Allow " tip-bot for Dave Hansen
2018-08-02 22:58 ` [PATCH 3/7] x86/mm/init: pass unconverted symbol addresses to free_init_pages() Dave Hansen
2018-08-04  0:18   ` Hugh Dickins
2018-08-04 17:31     ` Linus Torvalds
2018-08-04 18:23       ` Hugh Dickins
2018-08-05  6:11       ` Andi Kleen
2018-08-05 20:31   ` [tip:x86/pti] x86/mm/init: Pass " tip-bot for Dave Hansen
2018-08-02 22:58 ` [PATCH 4/7] x86/mm/init: add helper for freeing kernel image pages Dave Hansen
2018-08-05 20:32   ` [tip:x86/pti] x86/mm/init: Add " tip-bot for Dave Hansen
2018-08-02 22:58 ` [PATCH 5/7] x86/mm/init: remove freed kernel image areas from alias mapping Dave Hansen
2018-08-04  0:35   ` Hugh Dickins
2018-08-04 21:38   ` Andy Lutomirski
2018-08-06 15:17     ` Dave Hansen
2018-08-05 20:32   ` [tip:x86/pti] x86/mm/init: Remove " tip-bot for Dave Hansen
2018-08-06 20:21   ` [tip:x86/pti-urgent] " tip-bot for Dave Hansen
2018-08-02 22:58 ` [PATCH 6/7] x86/mm/pageattr: pass named flag instead of 0/1 Dave Hansen
2018-08-05 20:09   ` Thomas Gleixner
2018-08-06 15:09     ` Dave Hansen
2018-08-02 22:58 ` [PATCH 7/7] x86/mm/pageattr: Remove implicit NX behavior Dave Hansen

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