From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755635AbdIGSfx convert rfc822-to-8bit (ORCPT ); Thu, 7 Sep 2017 14:35:53 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:5248 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751576AbdIGSfw (ORCPT ); Thu, 7 Sep 2017 14:35:52 -0400 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 07 Sep 2017 11:35:30 -0700 From: Ralph Campbell To: Tycho Andersen , "linux-kernel@vger.kernel.org" CC: "linux-mm@kvack.org" , "kernel-hardening@lists.openwall.com" , Marco Benatto , Juerg Haefliger , "x86@kernel.org" Subject: RE: [PATCH v6 03/11] mm, x86: Add support for eXclusive Page Frame Ownership (XPFO) Thread-Topic: [PATCH v6 03/11] mm, x86: Add support for eXclusive Page Frame Ownership (XPFO) Thread-Index: AQHTKAAr9ZWZlpuCFkGPsJWC0rspzaKpugwA Date: Thu, 7 Sep 2017 18:33:09 +0000 Message-ID: References: <20170907173609.22696-1-tycho@docker.com> <20170907173609.22696-4-tycho@docker.com> In-Reply-To: <20170907173609.22696-4-tycho@docker.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [172.17.163.7] MIME-Version: 1.0 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: owner-linux-mm@kvack.org [mailto:owner-linux-mm@kvack.org] On > Behalf Of Tycho Andersen > Sent: Thursday, September 7, 2017 10:36 AM > To: linux-kernel@vger.kernel.org > Cc: linux-mm@kvack.org; kernel-hardening@lists.openwall.com; Marco Benatto > ; Juerg Haefliger > ; x86@kernel.org; Tycho Andersen > > Subject: [PATCH v6 03/11] mm, x86: Add support for eXclusive Page Frame > Ownership (XPFO) > > From: Juerg Haefliger > > This patch adds support for XPFO which protects against 'ret2dir' kernel attacks. > The basic idea is to enforce exclusive ownership of page frames by either the > kernel or userspace, unless explicitly requested by the kernel. Whenever a page > destined for userspace is allocated, it is unmapped from physmap (the kernel's > page table). When such a page is reclaimed from userspace, it is mapped back to > physmap. > > Additional fields in the page_ext struct are used for XPFO housekeeping, > specifically: > - two flags to distinguish user vs. kernel pages and to tag unmapped > pages. > - a reference counter to balance kmap/kunmap operations. > - a lock to serialize access to the XPFO fields. > > This patch is based on the work of Vasileios P. Kemerlis et al. who published their > work in this paper: > http://www.cs.columbia.edu/~vpk/papers/ret2dir.sec14.pdf > > v6: * use flush_tlb_kernel_range() instead of __flush_tlb_one, so we flush > the tlb entry on all CPUs when unmapping it in kunmap > * handle lookup_page_ext()/lookup_xpfo() returning NULL > * drop lots of BUG()s in favor of WARN() > * don't disable irqs in xpfo_kmap/xpfo_kunmap, export > __split_large_page so we can do our own alloc_pages(GFP_ATOMIC) to > pass it > > CC: x86@kernel.org > Suggested-by: Vasileios P. Kemerlis > Signed-off-by: Juerg Haefliger > Signed-off-by: Tycho Andersen > Signed-off-by: Marco Benatto > --- > Documentation/admin-guide/kernel-parameters.txt | 2 + > arch/x86/Kconfig | 1 + > arch/x86/include/asm/pgtable.h | 25 +++ > arch/x86/mm/Makefile | 1 + > arch/x86/mm/pageattr.c | 22 +-- > arch/x86/mm/xpfo.c | 114 ++++++++++++ > include/linux/highmem.h | 15 +- > include/linux/xpfo.h | 42 +++++ > mm/Makefile | 1 + > mm/page_alloc.c | 2 + > mm/page_ext.c | 4 + > mm/xpfo.c | 222 ++++++++++++++++++++++++ > security/Kconfig | 19 ++ > 13 files changed, 449 insertions(+), 21 deletions(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt > b/Documentation/admin-guide/kernel-parameters.txt > index d9c171ce4190..444d83183f75 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -2736,6 +2736,8 @@ > > nox2apic [X86-64,APIC] Do not enable x2APIC mode. > > + noxpfo [X86-64] Disable XPFO when CONFIG_XPFO is on. > + > cpu0_hotplug [X86] Turn on CPU0 hotplug feature when > CONFIG_BOOTPARAM_HOTPLUG_CPU0 is off. > Some features depend on CPU0. Known dependencies <... snip> A bit more description for system administrators would be very useful. Perhaps something like: noxpfo [XPFO,X86-64] Disable eXclusive Page Frame Ownership (XPFO) Physical pages mapped into user applications will also be mapped in the kernel's address space as if CONFIG_XPFO was not enabled. Patch 05 should also update kernel-parameters.txt and add "ARM64" to the config option list for noxpfo.