From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753280AbdLDQ52 (ORCPT ); Mon, 4 Dec 2017 11:57:28 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:60647 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753073AbdLDQv5 (ORCPT ); Mon, 4 Dec 2017 11:51:57 -0500 Message-Id: <20171204150609.416845605@linutronix.de> User-Agent: quilt/0.63-1 Date: Mon, 04 Dec 2017 15:08:02 +0100 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andy Lutomirsky , Peter Zijlstra , Dave Hansen , Borislav Petkov , Greg KH , keescook@google.com, hughd@google.com, Brian Gerst , Josh Poimboeuf , Denys Vlasenko , Rik van Riel , Boris Ostrovsky , Juergen Gross , David Laight , Eduardo Valentin , aliguori@amazon.com, Will Deacon , daniel.gruss@iaik.tugraz.at, Dave Hansen , Ingo Molnar , moritz.lipp@iaik.tugraz.at, linux-mm@kvack.org, Borislav Petkov , michael.schwarz@iaik.tugraz.at, richard.fellner@student.tugraz.at Subject: [patch 56/60] x86/mm/kpti: Disable native VSYSCALL References: <20171204140706.296109558@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=x86-mm-kpti--Disable_native_VSYSCALL.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen The KERNEL_PAGE_TABLE_ISOLATION code attempts to "poison" the user portion of the kernel page tables. It detects entries that it wants that it wants to poison in two ways: * Looking for addresses >= PAGE_OFFSET * Looking for entries without _PAGE_USER set But, to allow the _PAGE_USER check to work, it must never be set on init_mm entries, and an earlier patch in this series ensured that it will never be set. The VDSO is at a address >= PAGE_OFFSET and it is also mapped by init_mm. Because of the earlier, KERNEL_PAGE_TABLE_ISOLATION-enforced restriction, _PAGE_USER is never set which makes the VDSO unreadable to userspace. This makes the "NATIVE" case totally unusable since userspace can not even see the memory any more. Disable it whenever KERNEL_PAGE_TABLE_ISOLATION is enabled. Also add some help text about how KERNEL_PAGE_TABLE_ISOLATION might affect the emulation case as well. Signed-off-by: Dave Hansen Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Cc: Rik van Riel Cc: keescook@google.com Cc: Denys Vlasenko Cc: moritz.lipp@iaik.tugraz.at Cc: linux-mm@kvack.org Cc: Peter Zijlstra Cc: Brian Gerst Cc: hughd@google.com Cc: daniel.gruss@iaik.tugraz.at Cc: Borislav Petkov Cc: Andy Lutomirski Cc: Josh Poimboeuf Cc: michael.schwarz@iaik.tugraz.at Cc: Linus Torvalds Cc: richard.fellner@student.tugraz.at Link: https://lkml.kernel.org/r/20171123003513.10CAD896@viggo.jf.intel.com --- arch/x86/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2249,6 +2249,9 @@ choice config LEGACY_VSYSCALL_NATIVE bool "Native" + # The VSYSCALL page comes from the kernel page tables + # and is not available when KERNEL_PAGE_TABLE_ISOLATION is enabled. + depends on !KERNEL_PAGE_TABLE_ISOLATION help Actual executable code is located in the fixed vsyscall address mapping, implementing time() efficiently. Since @@ -2266,6 +2269,11 @@ choice exploits. This configuration is recommended when userspace still uses the vsyscall area. + When KERNEL_PAGE_TABLE_ISOLATION is enabled, the vsyscall area will become + unreadable. This emulation option still works, but KERNEL_PAGE_TABLE_ISOLATION + will make it harder to do things like trace code using the + emulation. + config LEGACY_VSYSCALL_NONE bool "None" help