Received: by 10.223.176.46 with SMTP id f43csp3257271wra; Mon, 22 Jan 2018 10:56:34 -0800 (PST) X-Google-Smtp-Source: AH8x224dhc0/9zr8UmGNKf5dWQ7vSR+O1IkRJQrIOif8owGSc+Fr5fZ7TgGaqCBDGUeLZHFBpTQS X-Received: by 10.107.171.199 with SMTP id u190mr8847472ioe.95.1516647394027; Mon, 22 Jan 2018 10:56:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516647393; cv=none; d=google.com; s=arc-20160816; b=XmBTuAcY1VHLhqHf93S0mkXY4Ss4azndwJnKdNWBXBOvtg7mOoj3OmAivmgsh3yGvS D9GloFvMyCw8aKeSoIEnjOnzGJSYji2TxkhmzWhqMsYXoajbwaWcX7Y6SSyR66izXEjb mQJVe/rgCtJakTyAX7VrmSh8djN2Wss9QRWy88TQEE8nB2SXkjtRX12G7DjO3yJiy4xT 1SXmg1mCCdEcA/b5WukXyGglV5Cxjec0zwS3BmDilMR7D3K8fgmmWgn0UQEPMHIVzXqz 3HL+ehN6iAKxoUh9qjbCho6M8a2tHpOzHqDYqG5FjjqosnwoxFQk0Ni3FzvOTo9Q87dS zhWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ECHEhTA2UcYgaeeSefVPFVMDvMvYar5ihledEHZDZ+4=; b=g6jfH1rwWDkVdTjtTJoyE7EU9u8DJNSZGHP0zzUPc1HKAmGEOTrkjP1MMfBnI3h758 AVsJ7Gmru//IMgS92+0GoUh4msIy+nb5ByGu1lku1QzFcwtWCranTAa1DjSbIf8MTvma Q2AmKegBgJO0qf3H8PcHsIwn7oXK3QNG3BmGFyguU+8xWGEEaELHGTz2DOTgOXDzEQaF bSQcr6EFyK52qY1VMPg2V8a3EbQcfTne/entJ5AqPP/PCzblcNrnjXIo+y/xcgiklc5I +K/p2qMXo3jy7wk60W9nJyvpeT3FoC97tu9pf22NwqR7fcA9SgNys6gdCxfzHTr/I0K7 9hxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pVe2HCEE; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c187si6763171ith.149.2018.01.22.10.56.21; Mon, 22 Jan 2018 10:56:33 -0800 (PST) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pVe2HCEE; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751531AbeAVSxo (ORCPT + 99 others); Mon, 22 Jan 2018 13:53:44 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:42697 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751459AbeAVSxk (ORCPT ); Mon, 22 Jan 2018 13:53:40 -0500 Received: by mail-qt0-f194.google.com with SMTP id c2so23470411qtn.9; Mon, 22 Jan 2018 10:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ECHEhTA2UcYgaeeSefVPFVMDvMvYar5ihledEHZDZ+4=; b=pVe2HCEEW5KFg9caJa9RNM6E5biRfGpCMxQp4AWfJbTa2XJlZNTCcNs7db+bAF2YL/ L0SsOBtNvDk6luSP1l2YpxxRWehjfszmSKgr8bXvuOKfkHLPbMPMFO1pc7xGm8pSUkph OYJly/tHSaG8NgoxPVFOjKN91I1N2T+GRD39Of2T4Z8+TADopGa1ZdOeoLVjghirs7Ep sEh2/G7AuisYlQtU8YAKc+BqMCWmqNeIJ+W1iB5fEjNyQXQUj+U0vyLhrAtaSxZQHRV4 axxJI7+pWxrU58bWv65iSZH3kbE9Wp3WxSEPg73xoBcvfhoDUwKOJ6uP/go0Y5RM04Wq 4QJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ECHEhTA2UcYgaeeSefVPFVMDvMvYar5ihledEHZDZ+4=; b=rvV2XDt+Ud8Q0GNR2K3+ptxg4s5snvaBnvPJHRwHtnbhI0T6J/OiySVCgD2Hf/UqJC g/L3NGrXsMoDiuotkPaVJKg9eV6h2Cm/vn8aieN5p3rkvN7S6KQ0UFi0wlTKmpwBiCnG TvTjkmhrc47onL1i/3WY7oaGQq7h4CfVPqjR1n23Pcs3UdpkHT+ZCvVr593VonBbJW4z GGenLwOB1UvCHr7nuiY0Q+zyWHsc7w2d6yZYNwSOUtiC8g+u+9EK/tSMg88Ormtjw+wt 4ist7W8qaZW+If95wTK/e/0AnspyoCM3b+O2b8InW+1F2F/O57OQzpeXsusXWtAtzS4N UozA== X-Gm-Message-State: AKwxytcf0H6xkksNo39pRvbwdS1UVKRWz4saAeDYjos6TfO0ADRPm5pN 0Y4ZseZ0GuqDt3HCK37FQK8= X-Received: by 10.237.60.9 with SMTP id t9mr12537558qte.228.1516647219551; Mon, 22 Jan 2018 10:53:39 -0800 (PST) Received: from localhost.localdomain (50-39-100-161.bvtn.or.frontiernet.net. [50.39.100.161]) by smtp.gmail.com with ESMTPSA id o20sm10790061qkl.14.2018.01.22.10.53.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 10:53:39 -0800 (PST) From: Ram Pai To: shuahkh@osg.samsung.com, linux-kselftest@vger.kernel.org Cc: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, akpm@linux-foundation.org, dave.hansen@intel.com, benh@kernel.crashing.org, paulus@samba.org, khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, hbabu@us.ibm.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, ebiederm@xmission.com, linuxram@us.ibm.com, arnd@arndb.de Subject: [PATCH v10 17/24] selftests/vm: associate key on a mapped page and detect access violation Date: Mon, 22 Jan 2018 10:52:10 -0800 Message-Id: <1516647137-11174-18-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1516647137-11174-1-git-send-email-linuxram@us.ibm.com> References: <1516647137-11174-1-git-send-email-linuxram@us.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org detect access-violation on a page to which access-disabled key is associated much after the page is mapped. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index 33d5839..1d3f596 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1016,6 +1016,24 @@ void test_read_of_access_disabled_region(int *ptr, u16 pkey) dprintf1("*ptr: %d\n", ptr_contents); expected_pkey_fault(pkey); } + +void test_read_of_access_disabled_region_with_page_already_mapped(int *ptr, + u16 pkey) +{ + int ptr_contents; + + dprintf1("disabling access to PKEY[%02d], doing read @ %p\n", + pkey, ptr); + ptr_contents = read_ptr(ptr); + dprintf1("reading ptr before disabling the read : %d\n", + ptr_contents); + rdpkey_reg(); + pkey_access_deny(pkey); + ptr_contents = read_ptr(ptr); + dprintf1("*ptr: %d\n", ptr_contents); + expected_pkey_fault(pkey); +} + void test_write_of_write_disabled_region(int *ptr, u16 pkey) { dprintf1("disabling write access to PKEY[%02d], doing write\n", pkey); @@ -1310,6 +1328,7 @@ void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey) void (*pkey_tests[])(int *ptr, u16 pkey) = { test_read_of_write_disabled_region, test_read_of_access_disabled_region, + test_read_of_access_disabled_region_with_page_already_mapped, test_write_of_write_disabled_region, test_write_of_access_disabled_region, test_kernel_write_of_access_disabled_region, -- 1.7.1