Received: by 10.213.65.68 with SMTP id h4csp792990imn; Sun, 18 Mar 2018 02:33:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELvCCqNHkE9gkwrMa6zwPN38wi8yBe3fqUaaRqeNAUzWQoRYoaeiymiDVAH7nSbIBwLNKw8R X-Received: by 10.98.133.193 with SMTP id m62mr6848671pfk.74.1521365583090; Sun, 18 Mar 2018 02:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521365583; cv=none; d=google.com; s=arc-20160816; b=pOkfEtKjS2R8yP/M11C2fEbQT01hvLahvLpXh2ibQlLl+mQpyA/M55KPBNNaIKA8lM rqN5xYUcNhFrQw4FJjltkwvV0D5NABx+A4PNlqUG5gCZ7HYv4sabYhdTJqouyyNTQY1Y rZ3zYVBSfX93bm32mYocMgzs8pXjYw7peHwR7W9UecHV0+c3GLx0mjGdcVBMDYId2oHD 2iuvxCArHpnaQh0W2ownbnmiXj37tmEq2rbdlcy+jh2PDkQvcMLhJZinanez6QOlTK+U niNS+f9o8TIDou1BjZnBcMLcKDgImEldokrGwuCB01PNRcxirbo83ujVkX1liFY5+JxO 5EaQ== 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=lb5o5U4vVNH0oaOT6U0L05nNxIpVl5QR4gp6NA6bofU=; b=TE0+8eKjlvPlsGaQIbMIiB9ofydjhP5nKvMRBffQh+8r96KiA+cBVCvgGC0fASi4RE 1/K6ewERp6WUhmG+9wfGxGjl/3Deny4l215aGxJkl363rL55GDqRQQ+lNHRCj9ZlUQy2 cOZxqQnGnu1eZLH+1KUCGQF7vvBJaBn0WhJCCncJDevjAHhHn9qUowtNEePcyw/GJaqa kBGFHTiW0yw393+YaqOeVXziSKueNEFzl7f727GI7v3IH8BT7DhISLnGGwDpeArXXmrh Io5dJueTXQKOSE+cO0C5eynAdFVJaSX16S5HJHGo5MO/uLD8oU4bODA/5NfPfeMvKuhh ZUjA== 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 g4-v6si9881936plb.114.2018.03.18.02.32.49; Sun, 18 Mar 2018 02:33:03 -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 S1753497AbeCRJa7 (ORCPT + 99 others); Sun, 18 Mar 2018 05:30:59 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:58308 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbeCRJa6 (ORCPT ); Sun, 18 Mar 2018 05:30:58 -0400 Received: from p4fea5f09.dip0.t-ipconnect.de ([79.234.95.9] helo=nanos.glx-home) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1exUeP-0008Oa-Rq; Sun, 18 Mar 2018 10:30:49 +0100 Date: Sun, 18 Mar 2018 10:30:48 +0100 (CET) From: Thomas Gleixner To: Ram Pai cc: Dave Hansen , linux-kernel@vger.kernel.org, linux-mm@kvack.org, dave.hansen@intel.com, mpe@ellerman.id.au, mingo@kernel.org, akpm@linux-foundation.org, shuah@kernel.org Subject: Re: [PATCH 1/3] x86, pkeys: do not special case protection key 0 In-Reply-To: <20180317232425.GH1060@ram.oc3035372033.ibm.com> Message-ID: References: <20180316214654.895E24EC@viggo.jf.intel.com> <20180316214656.0E059008@viggo.jf.intel.com> <20180317232425.GH1060@ram.oc3035372033.ibm.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 17 Mar 2018, Ram Pai wrote: > On Fri, Mar 16, 2018 at 02:46:56PM -0700, Dave Hansen wrote: > > > > From: Dave Hansen > > > > mm_pkey_is_allocated() treats pkey 0 as unallocated. That is > > inconsistent with the manpages, and also inconsistent with > > mm->context.pkey_allocation_map. Stop special casing it and only > > disallow values that are actually bad (< 0). > > > > The end-user visible effect of this is that you can now use > > mprotect_pkey() to set pkey=0. > > > > This is a bit nicer than what Ram proposed because it is simpler > > and removes special-casing for pkey 0. On the other hand, it does > > allow applciations to pkey_free() pkey-0, but that's just a silly > > thing to do, so we are not going to protect against it. > > So your proposal > (a) allocates pkey 0 implicitly, > (b) does not stop anyone from freeing pkey-0 > (c) and allows pkey-0 to be explicitly associated with any address range. > correct? > > My proposal > (a) allocates pkey 0 implicitly, > (b) stops anyone from freeing pkey-0 > (c) and allows pkey-0 to be explicitly associated with any address range. > > So the difference between the two proposals is just the freeing part i.e (b). > Did I get this right? Yes, and that's consistent with the other pkeys. > Its a philosophical debate; allow the user to shoot-in-the-feet or stop > from not doing so. There is no clear answer either way. I am fine either > way. The user can shoot himself already with the other pkeys, so adding another one does not matter and is again consistent. Thanks, tglx