Received: by 10.223.164.200 with SMTP id h8csp925457wrb; Mon, 6 Nov 2017 01:05:07 -0800 (PST) X-Google-Smtp-Source: ABhQp+RmdWZuxiEeh+bRGepyYy8U1bFOgSZC0JBty/G4TzfrwS8bY0QJq3SOzvDHXyoBKBLDBQnG X-Received: by 10.99.181.67 with SMTP id u3mr14872555pgo.118.1509959107832; Mon, 06 Nov 2017 01:05:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509959107; cv=none; d=google.com; s=arc-20160816; b=Uq7W1hINo3Z7Skwc0mY+NwxswUfvhJBlmFvkEOU5e5YbD+BKRNmcHcXjHK+APk3Fv7 S+VCK8dBIffx/qikoU/Xps0o+KM7rD+4A3vPGyh0LB3TFvlTc569qxEbIs1EM+/4sSeQ /VGrgY49LyLnPDNJ3F8GEaUKfbN1LqSKdOZQNkET7mk7a5gnERrJDzatSo6qjsbUAylM KBcpubVSIArDyeMqvOzFvxCwRZrzxFxOPVAd0Ry6/bbBd+Yu51KMyjKDGffaXDouwRB3 x29VYlGoWpM4j7V1FGMcrkN/soUPn75MjHO6Kip8aiuxzV+r0Ow38P4GjA9cn8atcYQk whWg== 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=wXQlxck3qXvZUwFZ8mSMsuzi0yNaei+N93rU7zFXXmQ=; b=eP9E9R/T47PM68phwCng0A8c/hJW+LVAPdN1EOO5e+2RcUc11Z3995t14FSFkimQA0 1IWiMUUPlGbw0g55/yllnZ6KAumZpbu5jVXczpKJ3X7gGwKzhADUkoZ40SvgiwGWtbQn ayylq+iTZLsUSXWdbpId4p1GPJyvt5DqaMvwdClgJ7NRNOWUYZhwC5cKq9o9SwS/H7DF UqJzxtVOphUcQNtPU9Tt/PuceYL5gtVApjg/AUKqdoIAQNL+xx6KA1nmyrvpGqhVc/og zXKjxm4m2Ci/dvuRD9oZ1I+ySWvsCZlhgADGBzbr+BVh672dcq246HdoVRAGyNCL8NaA oqcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=DoVDjfJa; 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 p82si11981470pfi.86.2017.11.06.01.04.54; Mon, 06 Nov 2017 01:05:07 -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=DoVDjfJa; 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 S1752695AbdKFJAi (ORCPT + 98 others); Mon, 6 Nov 2017 04:00:38 -0500 Received: from mail-qk0-f193.google.com ([209.85.220.193]:46252 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752670AbdKFJAd (ORCPT ); Mon, 6 Nov 2017 04:00:33 -0500 Received: by mail-qk0-f193.google.com with SMTP id o6so3057139qkh.3; Mon, 06 Nov 2017 01:00:32 -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=wXQlxck3qXvZUwFZ8mSMsuzi0yNaei+N93rU7zFXXmQ=; b=DoVDjfJaXgKJQZACzueptP6QhSzHJyAQ8hYM6P9+lCXKzR6S69D2AGvRMhQakLp99b 1gg5lK6N+frXVX0ee6OX99VSBb1oEJED33hBBg55MezJA4RL2eNKdYzx0JBvjY/XBdMy YILS5/GfTdNw1Ly6TvnoJY2MNfuSryNMkRhu5ro1bPr6spJOoGxFWusQtcRMVJSkzYw1 VcRYtgevwHfThlQt1354Y+VAQm+9Dh68cMGxBcaL/AhOM1aPht6v8/cIKZ5DA1/IhZwK LlcJqgYkW5J3s4BsoGrIoA5w56UfFp/DaH5nCD9tnggTTOS2FRPmUFFB0asMPR+jPOXO pYvw== 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=wXQlxck3qXvZUwFZ8mSMsuzi0yNaei+N93rU7zFXXmQ=; b=YjpJfNjKrbC/bV9k+yg1APsvPkuuZEl22nlEvCX/7Nww1HMlJXkKFii/y+I+7GWZ/u RXodKzw29vtPHxLO7gT6PZwYTvQkXRlRuIEkQxOjgTF2PC7NKopND+OFoVQ8DpWhv1hQ xSI/+e40S8sSW68CMA5WtNzgF/OQMj8403CGU0H7SfBQG2gqIET1IvVv9SVPJryjpBru rgUlrHeSVCQ1I36ib2riSO7xUc47xclAr7AWdEbY/mxZPF/43ZQpt8PaErRqz69eyXYA tHkydTh5RNnfayoeKjmBmQesddzxcsDOGR8SFi5gsMYtPoJZJlKBCjjZry5UKyAgMq8P n2sQ== X-Gm-Message-State: AMCzsaXxX4gn5VIXR3jF3YYmhcUCNiam3H4rQs5iI1ZY770gWPDKfALs vJBtoR9rOjF0+SCyv3amjf4= X-Received: by 10.55.71.143 with SMTP id u137mr19801334qka.166.1509958832144; Mon, 06 Nov 2017 01:00:32 -0800 (PST) Received: from localhost.localdomain (50-39-103-96.bvtn.or.frontiernet.net. [50.39.103.96]) by smtp.gmail.com with ESMTPSA id r26sm8001094qki.42.2017.11.06.01.00.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 01:00:27 -0800 (PST) From: Ram Pai To: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org, corbet@lwn.net, arnd@arndb.de Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.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 Subject: [PATCH v9 46/51] selftest/vm: associate key on a mapped page and detect access violation Date: Mon, 6 Nov 2017 00:57:38 -0800 Message-Id: <1509958663-18737-47-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> References: <1509958663-18737-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 8f0dd94..998a44f 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1015,6 +1015,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); @@ -1309,6 +1327,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 From 1583368138859087934@xxx Tue Nov 07 01:18:47 +0000 2017 X-GM-THRID: 1583368138859087934 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread