Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753154AbdLMPce (ORCPT ); Wed, 13 Dec 2017 10:32:34 -0500 Received: from merlin.infradead.org ([205.233.59.134]:44768 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751090AbdLMPcb (ORCPT ); Wed, 13 Dec 2017 10:32:31 -0500 Date: Wed, 13 Dec 2017 16:32:02 +0100 From: Peter Zijlstra To: Dave Hansen Cc: "Kirill A. Shutemov" , Andy Lutomirski , Thomas Gleixner , LKML , X86 ML , Linus Torvalds , Borislav Petkov , Greg KH , Kees Cook , Hugh Dickins , Brian Gerst , Josh Poimboeuf , Denys Vlasenko , Boris Ostrovsky , Juergen Gross , David Laight , Eduardo Valentin , aliguori@amazon.com, Will Deacon , "linux-mm@kvack.org" , kirill.shutemov@linux.intel.com, aneesh.kumar@linux.vnet.ibm.com Subject: Re: [patch 05/16] mm: Allow special mappings with user access cleared Message-ID: <20171213153202.qtxnloxoc66lhsbf@hirez.programming.kicks-ass.net> References: <20171212173221.496222173@linutronix.de> <20171212173333.669577588@linutronix.de> <20171213122211.bxcb7xjdwla2bqol@hirez.programming.kicks-ass.net> <20171213125739.fllckbl3o4nonmpx@node.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 933 Lines: 28 On Wed, Dec 13, 2017 at 07:14:41AM -0800, Dave Hansen wrote: > On 12/13/2017 04:57 AM, Kirill A. Shutemov wrote: > > Dave, what is effect of this on protection keys? > > The goal was to make pkeys-protected userspace memory access > _consistent_ with normal access. Specifically, we want a kernel to > disallow access (or writes) to memory where userspace mapping has a pkey > whose permissions are in conflict with the access. > > For instance: > > This will fault writing a byte to 'addr': > > char *addr = malloc(PAGE_SIZE); > pkey_mprotect(addr, PAGE_SIZE, 13); > pkey_deny_access(13); > *addr[0] = 'f'; > > But this will write one byte to addr successfully (if it uses the kernel > mapping of the physical page backing 'addr'): > > char *addr = malloc(PAGE_SIZE); > pkey_mprotect(addr, PAGE_SIZE, 13); > pkey_deny_access(13); > read(fd, addr, 1); > This seems confused to me; why are these two cases different?