From patchwork Mon Nov 6 08:57:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 834622 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yVqW83tcdz9s7p for ; Mon, 6 Nov 2017 22:06:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tHijZIg1"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yVqW82M13zDqlM for ; Mon, 6 Nov 2017 22:06:28 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tHijZIg1"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400d:c0d::241; helo=mail-qt0-x241.google.com; envelope-from=ram.n.pai@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tHijZIg1"; dkim-atps=neutral Received: from mail-qt0-x241.google.com (mail-qt0-x241.google.com [IPv6:2607:f8b0:400d:c0d::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yVmjx1chlzDr5S for ; Mon, 6 Nov 2017 20:00:37 +1100 (AEDT) Received: by mail-qt0-x241.google.com with SMTP id j58so10032832qtj.0 for ; Mon, 06 Nov 2017 01:00:37 -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=XVTVT1K0sYv3+LJ18cLmX7tWAtZZ/EkUDIt17uAxzp5mEypYJqCBtzlBiT5XWK5JJi v0iEaLZ1+5dLv4AD6FLnx9ElmvEL4OiboTErQZ7dOkwdP8957cB8veUiasHlJFFI+JYJ a/VMKnKbJjD7fItCpToQPnMqDJtdg27G4wf7BxshXRaLEmLow2lOAURz7EKU5YNAB+uE /p23YNt+R+KSii1p9BYge6aY8wENENB5JOMm6iFRHHfzX1p/ptfemLo+CXiHRBCXyAn9 5ZsiWrHBREy08C3uqSCgsk8Ic0TakhUdbsMsYZLDHFxQixJ0gSJnqeyHYCgLuYXY+23H zogA== X-Gm-Message-State: AMCzsaWMQEocIkrdlt1vLmzgvcvFziyEM9UVd5uZEwyK+7o6nGnbjG8L F8xDaK2ufPEC22k0Ta1LNfw= X-Google-Smtp-Source: ABhQp+RQ0BM70rCzd/aDNweenAkcCskgakDGd8eiU92UMeeRR8y8E/oQQoLYx9uuOGM8oo9fSiz6gA== 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 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> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, ebiederm@xmission.com, linux-doc@vger.kernel.org, x86@kernel.org, dave.hansen@intel.com, linux-kernel@vger.kernel.org, linuxram@us.ibm.com, mhocko@kernel.org, linux-mm@kvack.org, paulus@samba.org, aneesh.kumar@linux.vnet.ibm.com, linux-kselftest@vger.kernel.org, bauerman@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org, khandual@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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,