Received: by 10.192.165.148 with SMTP id m20csp1772866imm; Thu, 26 Apr 2018 01:57:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpoCZscCeZhtwStSaD+EL9ApENI5ORu7GtzxYzdWOshc6jan/+fjD+8Z0q64cXMHRaMCsn7 X-Received: by 2002:a17:902:2006:: with SMTP id n6-v6mr2967961pla.125.1524733072626; Thu, 26 Apr 2018 01:57:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524733072; cv=none; d=google.com; s=arc-20160816; b=0Vfaao5BdfZ7Ng0vVA129xASBtq2yH6Giz23CHJUpuSEG0CbOX6OT82q39qDq5Dxsq qCSc7CgWj0DBSyFkzWlEcN610468lNkApAglmG4iCBcOFMwvikKVQOORh7TZYwbhpKuC S5E6+oigFitE7ctQBMEkWgDvbP+Mec9ZZDvmeDUCv+hQLT/kTEdUzBeyZnI4bYJhAUqc UJb8RBpTXT20mcie7/NAeKsS5yPdJbiPUYEa7bSCfwCH5j2u6lKC09DNtoecRWAlpZ1v KVibMHYbh4CQN8voAc1DNMwjjhXHeT1dlGhnhi577UZao4sdEztXAa6W5tKBFRFFUcUc Wneg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=xeiQqBjKILZGgQRPlnT21cVia5u8OzCxq3OQx33KvFI=; b=mHvozeHd6GjBbKzjggzJoCgx7EMgkbInJPZSaQePhdugckKuJJyAXLZ8iqHL68ILB0 Un3Umapwo6pyavfwnxGBpyzk9RnkfNiv4WigW8Sorxn6OeQltzEcWfXops6T7M8CKxZH U3hhc7nMWaz1E2gkSoDB9ivn2roYAVc+JrfdFd3VrMZdl8anENbjM0vZMjQZ+XCG1pjJ v7Ninq0xtcwoqSz2XabLKKlfhg53kw1U3Ei0IS9Hs0Js0N8ABHs5+98eBztU55INp6d0 qLKBCZQ/4DTKUqeeQr4DGjqiEHMPovUQdafAGPpXpSJyFKvTkJTNuPgkGAAUaQ0TXfes AL5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7si15210918pga.543.2018.04.26.01.57.37; Thu, 26 Apr 2018 01:57:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755171AbeDZIzt (ORCPT + 99 others); Thu, 26 Apr 2018 04:55:49 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:46268 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754813AbeDZIzq (ORCPT ); Thu, 26 Apr 2018 04:55:46 -0400 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fBcgm-0000c9-Hc; Thu, 26 Apr 2018 10:55:40 +0200 Date: Thu, 26 Apr 2018 10:55:40 +0200 (CEST) From: Thomas Gleixner To: Shakeel Butt cc: Dave Hansen , LKML , Linux MM , stable@kernel.org, linuxram@us.ibm.com, Dave Hansen , mpe@ellerman.id.au, Ingo Molnar , Andrew Morton , shuah@kernel.org Subject: Re: [PATCH 4/9] x86, pkeys: override pkey when moving away from PROT_EXEC In-Reply-To: Message-ID: References: <20180326172721.D5B2CBB4@viggo.jf.intel.com> <20180326172727.025EBF16@viggo.jf.intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 25 Apr 2018, Shakeel Butt wrote: > On Mon, Mar 26, 2018 at 5:27 PM, Dave Hansen > wrote: > > > > From: Dave Hansen > > > > I got a bug report that the following code (roughly) was > > causing a SIGSEGV: > > > > mprotect(ptr, size, PROT_EXEC); > > mprotect(ptr, size, PROT_NONE); > > mprotect(ptr, size, PROT_READ); > > *ptr = 100; > > > > The problem is hit when the mprotect(PROT_EXEC) > > is implicitly assigned a protection key to the VMA, and made > > that key ACCESS_DENY|WRITE_DENY. The PROT_NONE mprotect() > > failed to remove the protection key, and the PROT_NONE-> > > PROT_READ left the PTE usable, but the pkey still in place > > and left the memory inaccessible. > > > > To fix this, we ensure that we always "override" the pkee > > at mprotect() if the VMA does not have execute-only > > permissions, but the VMA has the execute-only pkey. > > > > We had a check for PROT_READ/WRITE, but it did not work > > for PROT_NONE. This entirely removes the PROT_* checks, > > which ensures that PROT_NONE now works. > > > > Reported-by: Shakeel Butt > > > > Signed-off-by: Dave Hansen > > Fixes: 62b5f7d013f ("mm/core, x86/mm/pkeys: Add execute-only protection keys support") > > Hi Dave, are you planning to send the next version of this patch or > going with this one? Right, some enlightment would be appreciated. I'm lost in the dozen different threads discussing this back and forth. Thanks, tglx