Received: by 10.223.164.200 with SMTP id h8csp922428wrb; Mon, 6 Nov 2017 01:01:45 -0800 (PST) X-Google-Smtp-Source: ABhQp+RPnvIDgm5X8iqZdO0171WaoeAgvDvVS+1xv6bAiOg6CWXxy5LD7qBon6AF49f0sXiWp7lk X-Received: by 10.98.76.206 with SMTP id e75mr16111271pfj.57.1509958905747; Mon, 06 Nov 2017 01:01:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509958905; cv=none; d=google.com; s=arc-20160816; b=vLpcTrGHKe1d+N0Iow3zpvP8lx/1bAftj2LiPz9MeH5jfj5OQ7vEV1HqUIXAFTgMxP dc5n+THtUTe9A8vs5jQkit7T2k/Gc9MfGYEZqei5L/XEOL6/fGj08dZUqk3v7a3auBnh jCGDB+dVU4mwVaALalA3rut+qbnS4FCvHJAM9Ma9JR1qVMrhy1pw1S0Qod4rwOmXJiFY Wn6IOc9fUciNdECiP0hv4MajGcQQ3sUcDUv32B6keEb7I03TjizPiIctNxiRyPc424Hl n4gSbOS9c68/nEkzr7iV3z827jKvdqis/M6gi0f/ysW42VK6P3vkcq81fhCJQxUiULfH 6a1A== 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=dAmuUckQtSE/CMg+vauZTC9C9NSbgbmiVAd1bdxD9is=; b=ezS6oKQnaP7Q+P2/JX5OSvqmVgEHi8mhFUXMT/BCxxfg0oRob4r5rLJdE/yLT65mM9 R55Ic8YzUbcECJnLMP++lgt0ZUctvMi8iIqwgmqdQpJrE6+aweRLe1FHpUGVC3oHd7oQ v9bEcxyfqw+G3ImHvrynJSQ2JU7crRGsGSQdstXqKW8No+VxMxG7Zs1QUKL9OIqid000 D/28ajtjUCvSIw6O3bBWsXNQjvBBT+0a9mF8m3Y3hbss4c1U4dSwZeKsDv4PP9BFAgDk cbiEUpLxrhQMz0wkog7eEl+VPysTyO/YL7EM0koiYZp7mcZeQdnNLvLkW1ob3Erd+Pds gV9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=tHijZIg1; 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 t3si9569455plm.311.2017.11.06.01.01.32; Mon, 06 Nov 2017 01:01:45 -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=tHijZIg1; 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 S1752714AbdKFJAk (ORCPT + 98 others); Mon, 6 Nov 2017 04:00:40 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:44644 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752474AbdKFJAf (ORCPT ); Mon, 6 Nov 2017 04:00:35 -0500 Received: by mail-qt0-f196.google.com with SMTP id 8so10019052qtv.1; Mon, 06 Nov 2017 01:00:35 -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=dAmuUckQtSE/CMg+vauZTC9C9NSbgbmiVAd1bdxD9is=; b=tHijZIg1Bc22ngm2BmC/CO+dqg5pncQjLiQnmImUsbZoX+rGFUxE8P/HWJZS6A6Q8h 2pG3tiJt7mNWNH4saHL3J6Bjr13xPFN/BoDpQf3OuFuwgW78ha6QJfs0C5cRmzGdVgCb 0yw7lADVtqi0Dj65QAc+/cC8Ma0fUeN3oScRoMIDXqt3A3QdJLwtyeTsDOnVc/jsLIkC wLmcMqsHuBsXCRvZs86EjTYZpYwYfDkqW8rDBx6LJoUNWMiEOBe6SWJiZIFhF1oqK7os T7o/M3TAQI7TXq+/NxVwioHqG4vA2I7LsT3T3Lf4fYpBkco/65uQQeDbgQN8goNwNUN/ c3bw== 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=dAmuUckQtSE/CMg+vauZTC9C9NSbgbmiVAd1bdxD9is=; b=FuT8uJ2ohckNfDqr+rhTMNmBAwKAKIFE5P1uKAy4tnOAvYEC44nfG7jtil4M8z/EHA NoZXvdV9EY6J/2d6zi0uGlpHGFBMiCgE0IJg78vDFsuFn6GpyI8HXy0O2ovFpTpGTjGb ZjQIb3Wav+WnndrhH5foDho61vHbdtfqw7m6SuSeype4Dj9GTAIoVWJGtOm98ElmncJU Ai4gQuhRrSw1Fim2zvW4qKdD67sxNAGiyarncIKRiwtZCH403xpNfpLVJGrAxCiWYxrJ DN+qQq2ldsfOlpR8w3pS0Ob+BRqeUgJFeTFzpATXAh3oyAZaao+0qTkiV01nO+bdcMA7 V0EQ== X-Gm-Message-State: AMCzsaW2mEqJbZjX+yqrQIAoMTFdVqhjXwkWlMYgIy1S7703CKKF/90j 79m6bW75ayQV+FT/B6tGCQc= X-Received: by 10.200.6.70 with SMTP id e6mr21491650qth.15.1509958834674; Mon, 06 Nov 2017 01:00:34 -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.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 01:00:34 -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 47/51] selftest/vm: associate key on a mapped page and detect write violation Date: Mon, 6 Nov 2017 00:57:39 -0800 Message-Id: <1509958663-18737-48-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 write-violation on a page to which write-disabled key is associated much after the page is mapped. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index 998a44f..0b7b826 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1033,6 +1033,17 @@ void test_read_of_access_disabled_region_with_page_already_mapped(int *ptr, expected_pkey_fault(pkey); } +void test_write_of_write_disabled_region_with_page_already_mapped(int *ptr, + u16 pkey) +{ + *ptr = __LINE__; + dprintf1("disabling write access; after accessing the page, " + "to PKEY[%02d], doing write\n", pkey); + pkey_write_deny(pkey); + *ptr = __LINE__; + 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); @@ -1329,6 +1340,7 @@ void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey) 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_write_disabled_region_with_page_already_mapped, test_write_of_access_disabled_region, test_kernel_write_of_access_disabled_region, test_kernel_write_of_write_disabled_region, -- 1.7.1 From 1583309483287227405@xxx Mon Nov 06 09:46:29 +0000 2017 X-GM-THRID: 1583309483287227405 X-Gmail-Labels: Inbox,Category Promotions,HistoricalUnread