Received: by 10.213.65.68 with SMTP id h4csp596706imn; Fri, 23 Mar 2018 11:12:39 -0700 (PDT) X-Google-Smtp-Source: AG47ELth/m86P8T6v3MzCEgIygYvS4qryM/Esygg199jrl1VDLkmL/a3OQmSRDT9GQ72v+RpRMjY X-Received: by 2002:a17:902:5066:: with SMTP id f35-v6mr30637903plh.14.1521828759143; Fri, 23 Mar 2018 11:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521828759; cv=none; d=google.com; s=arc-20160816; b=s09fb2PzUTpjcGuwtgTpCTd8bBkpzhMa2ehD94HekfVOCu9oBqpRio9ixLY5JSpIK2 gCRE64sKfJhy3qp3aug/n89+2wO5FOh/lWctxSXAG2Usf5tNezyefqwMYfVQP//J8Zbm fqUh1MksyAipmANVmuZ6wNi8UB+Hom5DNb3Jjk2UUnkdhyRSLLHtsvEiHp6dCuv/0jUr k03HN3JevBkBw4RG/lvYkpPZ7uB/yJcGk5fIKhjeprYOEytBEb2aul2kxvXmtA5wbP4c YZJEA5jTXLFMyJhhYs6NafaSZEWQQDbSRHTY4SLTK67VOWDSTDJ9GsspO1K9Apcx2bbX QHkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:references:date :from:cc:to:subject:arc-authentication-results; bh=qXHNic+Hmqjvc9Kry4zHs8cKkoGrhHaVWzihf5DyF9I=; b=rWeZZYt2yL2EdU/2CwdsDbL4MG5crXYJRuPokyVJ/Xb36AT4F1aKZDnIuLW6YSsF+U i2vHS3oau3c2T8zmMj04Qhe0KehCfvGi035brxcMYya+IADor6wjWI6ZRnAP1wlayopo /A7Vklrmf9lBii+VvC3b3+HTTdyoDdrzSRIAnNJLjUnm/2DCrEwxbcQPy1Yu+E7d9jSM aNZjr+5lod5I6GjTT+5bZVpyKzmpwSuf7DqwAN+9f9/3rPyhs1ILzF3JZ+c4bTzylkBM ApP8rACxCOvCIap2pLHXpyBw1QwFDeLPIP6zpMFLaM7CCf5KaoB5O3PknIxnaddxA2wU dPgQ== 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 m61-v6si9144397plb.63.2018.03.23.11.12.24; Fri, 23 Mar 2018 11:12:39 -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 S1752458AbeCWSLV (ORCPT + 99 others); Fri, 23 Mar 2018 14:11:21 -0400 Received: from mga04.intel.com ([192.55.52.120]:12722 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752394AbeCWSLS (ORCPT ); Fri, 23 Mar 2018 14:11:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Mar 2018 11:11:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,351,1517904000"; d="scan'208";a="27492658" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.39.119]) by orsmga007.jf.intel.com with ESMTP; 23 Mar 2018 11:11:18 -0700 Subject: [PATCH 8/9] x86, pkeys, selftests: add allow faults on unknown keys To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Dave Hansen , linuxram@us.ibm.com, tglx@linutronix.de, dave.hansen@intel.com, mpe@ellerman.id.au, mingo@kernel.org, akpm@linux-foundation.org, shuah@kernel.org From: Dave Hansen Date: Fri, 23 Mar 2018 11:09:17 -0700 References: <20180323180903.33B17168@viggo.jf.intel.com> In-Reply-To: <20180323180903.33B17168@viggo.jf.intel.com> Message-Id: <20180323180917.DFF35209@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen The exec-only pkey is allocated inside the kernel and userspace is not told what it is. So, allow PK faults to occur that have an unknown key. Signed-off-by: Dave Hansen Cc: Ram Pai Cc: Thomas Gleixner Cc: Dave Hansen Cc: Michael Ellermen Cc: Ingo Molnar Cc: Andrew Morton Cc: Shuah Khan --- b/tools/testing/selftests/x86/protection_keys.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff -puN tools/testing/selftests/x86/protection_keys.c~pkeys-selftests-unknown-exec-only-key tools/testing/selftests/x86/protection_keys.c --- a/tools/testing/selftests/x86/protection_keys.c~pkeys-selftests-unknown-exec-only-key 2018-03-21 15:47:51.985198917 -0700 +++ b/tools/testing/selftests/x86/protection_keys.c 2018-03-21 15:47:51.988198917 -0700 @@ -922,13 +922,21 @@ void *malloc_pkey(long size, int prot, u } int last_pkru_faults; +#define UNKNOWN_PKEY -2 void expected_pk_fault(int pkey) { dprintf2("%s(): last_pkru_faults: %d pkru_faults: %d\n", __func__, last_pkru_faults, pkru_faults); dprintf2("%s(%d): last_si_pkey: %d\n", __func__, pkey, last_si_pkey); pkey_assert(last_pkru_faults + 1 == pkru_faults); - pkey_assert(last_si_pkey == pkey); + + /* + * For exec-only memory, we do not know the pkey in + * advance, so skip this check. + */ + if (pkey != UNKNOWN_PKEY) + pkey_assert(last_si_pkey == pkey); + /* * The signal handler shold have cleared out PKRU to let the * test program continue. We now have to restore it. _