From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752284AbbIXTKG (ORCPT ); Thu, 24 Sep 2015 15:10:06 -0400 Received: from www.sr71.net ([198.145.64.142]:59930 "EHLO blackbird.sr71.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751145AbbIXTKE (ORCPT ); Thu, 24 Sep 2015 15:10:04 -0400 Subject: Re: [PATCH 26/26] x86, pkeys: Documentation To: Ingo Molnar References: <20150916174903.E112E464@viggo.jf.intel.com> <20150916174913.AF5FEA6D@viggo.jf.intel.com> <20150920085554.GA21906@gmail.com> <55FF88BA.6080006@sr71.net> <20150924094956.GA30349@gmail.com> Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andrew Morton , Peter Zijlstra , Andy Lutomirski , Borislav Petkov , Kees Cook From: Dave Hansen Message-ID: <56044A88.7030203@sr71.net> Date: Thu, 24 Sep 2015 12:10:00 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150924094956.GA30349@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/24/2015 02:49 AM, Ingo Molnar wrote: > * Dave Hansen wrote: >>> Another question, related to enumeration as well: I'm wondering whether >>> there's any way for the kernel to allocate a bit or two for its own purposes - >>> such as protecting crypto keys? Or is the facility fundamentally intended for >>> user-space use only? >> >> No, that's not possible with the current setup. > > Ok, then another question, have you considered the following usecase: > > AFAICS pkeys only affect data loads and stores. Instruction fetches are notably > absent from the documentation. Can you clarify that instructions can be fetched > and executed from PTE_READ but pkeys-all-access-disabled pags? That is my understanding. I don't have a test for it, but I'll go make one. > If yes then this could be a significant security feature / usecase for pkeys: > executable sections of shared libraries and binaries could be mapped with pkey > access disabled. If I read the Intel documentation correctly then that should be > possible. Agreed. I've even heard from some researchers who are interested in this: https://www.infsec.cs.uni-saarland.de/wp-content/uploads/sites/2/2014/10/nuernberger2014ccs_disclosure.pdf > I.e. AFAICS pkeys could be used to create true '--x' permissions for executable > (user-space) pages. Just remember that all of the protections are dependent on the contents of PKRU. If an attacker controls the Access-Disable bit in PKRU for the executable-only region, you're sunk. But, that either requires being able to construct and execute arbitrary code *or* call existing code that sets PKRU to the desired values. Which, I guess, gets harder to do if all of the the wrpkru's are *in* the execute-only area.