From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965636AbbLRVpM (ORCPT ); Fri, 18 Dec 2015 16:45:12 -0500 Received: from mail-io0-f180.google.com ([209.85.223.180]:36845 "EHLO mail-io0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965225AbbLRVpH (ORCPT ); Fri, 18 Dec 2015 16:45:07 -0500 MIME-Version: 1.0 In-Reply-To: <567476CC.8080805@linux.intel.com> References: <56736BD1.5080700@linux.intel.com> <5673750B.606@linux.intel.com> <567453AF.5060808@linux.intel.com> <56746774.8000707@linux.intel.com> <567476CC.8080805@linux.intel.com> Date: Fri, 18 Dec 2015 13:45:06 -0800 X-Google-Sender-Auth: Vj27gtXFYVuEucuJqzeeqGRwI_Y Message-ID: Subject: Re: Rethinking sigcontext's xfeatures slightly for PKRU's benefit? From: Linus Torvalds To: Dave Hansen Cc: Andy Lutomirski , "H. Peter Anvin" , Oleg Nesterov , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Brian Gerst , "linux-kernel@vger.kernel.org" , Christoph Hellwig Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 18, 2015 at 1:12 PM, Dave Hansen wrote: > > But, if we are picking out an execute-only pkey more dynamically, we've > got to keep the default value for the entire process somewhere. How dynamic do we want to make this, though? I haven't looked at the details, and perhaps more importantly, I don't know what exactly are the requirements you've gotten from the people who are expected to actually use this. I think we might want to hardcode a couple of keys as "kernel reserved". And I'd rather reserve them up-front than have some user program be unhappy later when we want to use them. I guess we want to leave key #0 for "normal page", so my suggesting to use that for the execute-only was probably misguided. But I do think we might want to have that "no read access" as a real fixed key too, because I think the kernel itself would want to use it: (a) to make sure that it gets the right fault when user space passes in a execute-only address to a system call. (b) for much more efficient PAGEALLOC_DEBUG for kernel mappings. so I do think that we'd want to reserve two of the 16 keys up front. Would it be ok for the expected users to have those keys simply be fixed? With key 0 being used for all default pages, and key 1 being used for all execute-only pages? And then defaulting PKRU to 4, disallowing access to that key #1? I could imagine that some kernel person would want to use even more keys, but I think two fixed keys are kind of the minimal we'd want to use. Linus