Received: by 10.223.185.116 with SMTP id b49csp1380196wrg; Wed, 21 Feb 2018 18:00:02 -0800 (PST) X-Google-Smtp-Source: AH8x224Y3UDTMLxlYYhaa+sultfD/lz5MlDnR6LEXc3z+pFt1nK0wo5R2FmHC/XhlCiRM+F3ylLb X-Received: by 10.99.95.81 with SMTP id t78mr4265716pgb.380.1519264801892; Wed, 21 Feb 2018 18:00:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519264801; cv=none; d=google.com; s=arc-20160816; b=DsdIPUxpDfNGV0J+GZDnTsxOyZEKWe+8Fpg53bDC29p/SE3Hd6YDJyWZbt5dy22Lv9 /xD2m+uQQpuNmX0ZcrDDA2P6cfvr8WZ3n0I8uvUFfKsaGz8fF4YWj+KsZ/wqvdJiPHo+ +8o/HOgQN3Kq69w6yAZXHWuBgQ65R14L/pVXJNNDBWvj4ZRLN9WW2FKQUCdMLLpx7os6 yWcg1Ybd7UReqC0qNnW/SrIEl3ijUoxbJgIl2lKbT+rbAsVAR+05jHTSZtz9wUV69L8T R9uOLcqLRfa9Coo2Jxg7oJId21WdbOFhKEb64RHwCo+JMckqT0vWGGqxWcILDgoh7ntZ P7Zg== 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=F1Q8Pg2/NeJXGCNglceMKF0HTR854N/pSIX433WQwT8=; b=RNLo1Lf4eW0xm6McIGJwUsM58ku02t1LnifkZ0jsIKyBJ0l15WLMDlO79K6PBfP4um 6OY5AyGVJe66sOusIO/GipKBcqndu2lAKb2yycukEV5Oe18B+6RpFH3AHduo69Zs0Yb1 4lu1WA+ITbW1EY7gdQ63gbU4xoqVnxWkmKNLa/OmnPIZowBiuh+SpdDRcMCicYxoFOJ2 ikXzQEEa/0X1GjKFFNjAIMoD1DvX6zL7D0+M8RuwPhaBOnhbABDwQgpGZ1lLwqWyaqne gYhZjGprF+IRWDq0FoHjDwiiZ+V/c9srg9AHUY5fayclgNY+B5a3N8P18Qt/Q0uoJGKT dYfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=h7kO5LKs; 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 k33-v6si2460910pld.303.2018.02.21.17.59.47; Wed, 21 Feb 2018 18:00:01 -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=h7kO5LKs; 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 S1752391AbeBVB6j (ORCPT + 99 others); Wed, 21 Feb 2018 20:58:39 -0500 Received: from mail-qk0-f196.google.com ([209.85.220.196]:41534 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751838AbeBVB5S (ORCPT ); Wed, 21 Feb 2018 20:57:18 -0500 Received: by mail-qk0-f196.google.com with SMTP id h129so4626853qke.8; Wed, 21 Feb 2018 17:57:17 -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=F1Q8Pg2/NeJXGCNglceMKF0HTR854N/pSIX433WQwT8=; b=h7kO5LKsJ6LY2y6gP2hnihyNoxLmJceswYlF94X1hXSxm+GQtqGHSShWe9z7wRQWOn 6uGDXHWFllxVcZBr494qJ9GZOWtXDth2wR0Ujw5I7LncPZS0vkamWp4qVrkxIjKtBg00 CuPBDu9a4R/4jYckOceOTCkVeP1rrOCfU6FsqbmrpWTEsmGNXlCvlpHZUjNx/x75iW1J DdZYOJdpFfUGLfr7U1yzZwdXY+QysfnVOuaGVcQrvHuIJZYeRsGSBdVcZJuEh8EiQe0e TSyB4rA+3YvZ3BxhaQVcsWY/ZHEuOfEX2shbkOa3oS7BhXfdcELLkDQM30MIKaqdpScX HMMg== 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=F1Q8Pg2/NeJXGCNglceMKF0HTR854N/pSIX433WQwT8=; b=bB4hVH6kfRzURRXss7P5YOonkq4avwXQoPG7wJdIp0y5cycUrRcQu5Vmb7KvM/u4AW D4HaqYi5Sadu2TC7RSZVUZoh1I1F1A9/uwZqA9AM0d2c1LBJ1V+689D79J0KazXy0AW5 qyrP8++nqZti7iD9mYYJdGlrK1FggGk+V6SPOAwIdEOZezM4ePow5jCUQYBcPFdAbt+r qN8UJKi4fJKi2s1lcY1G7xUW/EEVBJDSXNO0RIHhH+wN8AbVwZ72k3rX5e2MTXCDLBNe 2e3GeAjBak1m2KN7LkvQfeazLFpoBdjyZNB/sDXF1eYjW4ubIBRu+/20Yz73TxbvujBV 9G8A== X-Gm-Message-State: APf1xPCErcFgLPX3kEbaKJGUXl2RC8yTaXARQ8diZCnmAUXhnLSQilz9 +wiYSvic2y1CXvg9afaWZcs= X-Received: by 10.55.1.78 with SMTP id 75mr7911886qkb.310.1519264637240; Wed, 21 Feb 2018 17:57:17 -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 n29sm14182630qtf.18.2018.02.21.17.57.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 17:57:16 -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 v12 17/22] selftests/vm: associate key on a mapped page and detect access violation Date: Wed, 21 Feb 2018 17:55:36 -0800 Message-Id: <1519264541-7621-18-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1519264541-7621-1-git-send-email-linuxram@us.ibm.com> References: <1519264541-7621-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. cc: Dave Hansen cc: Florian Weimer 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 aae6771..dba9162 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