From patchwork Thu Jun 14 00:45:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 10463115 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 792C1600D0 for ; Thu, 14 Jun 2018 00:48:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B4DB28988 for ; Thu, 14 Jun 2018 00:48:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F64E28BA8; Thu, 14 Jun 2018 00:48:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7AD428988 for ; Thu, 14 Jun 2018 00:48:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6261B6B0288; Wed, 13 Jun 2018 20:47:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5FE2E6B028A; Wed, 13 Jun 2018 20:47:27 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C88F6B028B; Wed, 13 Jun 2018 20:47:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f198.google.com (mail-qk0-f198.google.com [209.85.220.198]) by kanga.kvack.org (Postfix) with ESMTP id 1C7C16B0288 for ; Wed, 13 Jun 2018 20:47:27 -0400 (EDT) Received: by mail-qk0-f198.google.com with SMTP id w203-v6so3537584qkb.16 for ; Wed, 13 Jun 2018 17:47:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:sender:from:to:cc:subject:date :message-id:in-reply-to:references; bh=zzWUcYaAx3ymXQzetDNF6sp6hqYFLThITRR3DMRzHoI=; b=T+4Sxo66inKuFaDP2iNCxWHyxZ5iE8Vyrc2fl/2ClfFkonaN82WJyuiLXtunkl8dL3 MqCsWFlW9WLOPW37/oMWVVVHh+W7gpvBa/3z0jQWgxMXOhdyZK1Kdh4gUEJgkreY/9wS yrOfGVRuH/bnIDNIxLvWWvMwAHMaSpDFXUEzAqIsax/YZIhHuKbb9yyRx2avc5Nt+s/e 6GEzcC8vXsJ/dblp+RDAjKEs8y9Q7LY3gVEuTsG0m3iCCBwLRze2BaSZCogT5qHEk3CW HJ1l1AS5foyL05XiWnY8DsLs0rNouuh+hczBhx3sySAktAcANNJg5VLuWbWQi89j9WTh dQeA== X-Gm-Message-State: APt69E35bFPEtbmp1+e/vSfTKvCNmAlS/M2VWj4t4xy6ewF6ULTtqGp6 Khn1A3RzR64uUzBokRkfrd5HaC7ryQ3r/OKsFbzVj5fKNNj4zQBk4RN5w7opQ2uCz3XYhvcXatg tsq6PmIqP1//PnRxioZZ7tAhYwaKp2Q+NR14MQdAZ/FuUG3cfxTihjQgj77oJjPktZWOThphGy4 d+xfO/ilwpHik+tDGC0lqxSUxNNJl3L1HN/vAzWjgVHrHY9LBDmgxaaUXM0y4Wa7Tpn3wgYMX9Z +PbOHpMeiiUgLRehlhwbN9688i3jRGq7DKA6y6FcEjfGHKFWFrvXX72cTwsP1PEwCYHCB5an12Y BUgwXB8rarwDXCxXdDlkPWWvXtlmn5nQ7M3wSXzNKL88e4OK6PqlUbk9d2GU4+NoTzhxR31HHw= = X-Received: by 2002:a37:a80d:: with SMTP id r13-v6mr348663qke.41.1528937246922; Wed, 13 Jun 2018 17:47:26 -0700 (PDT) X-Received: by 2002:a37:a80d:: with SMTP id r13-v6mr348646qke.41.1528937246353; Wed, 13 Jun 2018 17:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528937246; cv=none; d=google.com; s=arc-20160816; b=Y1fMkv1VcgUMq/XbVqVKVnQTur3ko44jHEgFRrjEslXoUdCyUpZdkGIMqXWMGWcywR mikkFDtN8FUO8y825vMeGVyc7cuoVqjcPtR0U/s996pp9SY+uJFFMYt9sgNpBgD5NQAa OmtO9iZ3i+2NMSEpRk77U5U9n/noSVT61UHpZQwJMovSkqfX6Hwa6QlYmnLmVZd4t36E h+rQS5fq2EAsGsq7j8uxgd9KHq8EfZm6xTFWBUmV8okS/zNC2iHd+sv/VcciMkSj+r48 skud1sFeGsHcTELsqdD0oiz+1EUhzYnpztjiQKB88QgZwVmB8/ckz3c0NsP0K0lYwYxK CPjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature:arc-authentication-results; bh=zzWUcYaAx3ymXQzetDNF6sp6hqYFLThITRR3DMRzHoI=; b=B6xodMno6X+8K3qSkXoZa5G/6TzyPEzOvLPqwZcRkOY8axyFr7zUSV3z763+560VTb QtmmnmxSAaMOfX4vQt9+7AtlZJbN7KZJGW4/sB9J55z9M7U3Xo4NHP1HnF9RgPH26u3f ErLDjG23EAsiPOVi25xuJN0QIdWwYqHYxbK2Z0oBdIq1dOem1w0juDIJBJS+7lZxyrh5 KuHo3mzgepgt+K9zgFw8zmxUzyO79cIhb46xFBdB12gWeP5yXnrHLHhhHbhSyhnPV5my 9X3c3jzBmM5VmtOZcwp+ebC3CqwNM8IHdNfGwUNHz+MGo3+L6EdFe9LGNavTBtzaqg+2 +OEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=texq5GGk; spf=pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ram.n.pai@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id i133-v6sor2077695qke.49.2018.06.13.17.47.26 for (Google Transport Security); Wed, 13 Jun 2018 17:47:26 -0700 (PDT) Received-SPF: pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=texq5GGk; spf=pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ram.n.pai@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com 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=zzWUcYaAx3ymXQzetDNF6sp6hqYFLThITRR3DMRzHoI=; b=texq5GGkm0ef19ZlWZUgrKjzPICz6pTt8VqTVkmvNenCtq5O9huhFguNypmwvIpf/+ mYKM6cvlakh2EVfhgOhMwE2/EaIRxFt3ghctty77TA94tfPnz7TZBysDnNTkySOlddWp ypsTqQsaq3yezQE0+Aew3kx4s5SEQtShzCyDhBwrOPtPX1yJURXPyLkw3MKeVP0DYyl1 y6VQqnctDfRXwZso1lXO+i256T3F0WcmQHJrGjSAEOCHXDaHaqGvEniSgZLJ27N42Zyw H2WEvn8JT35wInHgisCeeaLchv+N7f8zPQ3Xmpi2I5q4ZFg95TXjV80MZI/+wRtFd8n9 aD6A== X-Google-Smtp-Source: ADUXVKKtugMovozDtjsj875JUbtxPWLqAT0zoKBe7podbiJUgEKXsTUOqZIB27BpYn7AUfo/QqxRMw== X-Received: by 2002:a37:3389:: with SMTP id z131-v6mr333796qkz.309.1528937246167; Wed, 13 Jun 2018 17:47:26 -0700 (PDT) Received: from localhost.localdomain (50-39-100-161.bvtn.or.frontiernet.net. [50.39.100.161]) by smtp.gmail.com with ESMTPSA id u31-v6sm3225898qtc.28.2018.06.13.17.47.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 17:47:25 -0700 (PDT) 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, mingo@redhat.com, dave.hansen@intel.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, linuxram@us.ibm.com, fweimer@redhat.com, msuchanek@suse.de, aneesh.kumar@linux.vnet.ibm.com Subject: [PATCH v13 21/24] selftests/vm: detect write violation on a mapped access-denied-key page Date: Wed, 13 Jun 2018 17:45:12 -0700 Message-Id: <1528937115-10132-22-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1528937115-10132-1-git-send-email-linuxram@us.ibm.com> References: <1528937115-10132-1-git-send-email-linuxram@us.ibm.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP detect write-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 Acked-by: Dave Hansen --- tools/testing/selftests/vm/protection_keys.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index f4acd72..caf634e 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1067,6 +1067,18 @@ void test_write_of_access_disabled_region(int *ptr, u16 pkey) *ptr = __LINE__; expected_pkey_fault(pkey); } + +void test_write_of_access_disabled_region_with_page_already_mapped(int *ptr, + u16 pkey) +{ + *ptr = __LINE__; + dprintf1("disabling access; after accessing the page, " + " to PKEY[%02d], doing write\n", pkey); + pkey_access_deny(pkey); + *ptr = __LINE__; + expected_pkey_fault(pkey); +} + void test_kernel_write_of_access_disabled_region(int *ptr, u16 pkey) { int ret; @@ -1435,6 +1447,7 @@ void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey) test_write_of_write_disabled_region, test_write_of_write_disabled_region_with_page_already_mapped, test_write_of_access_disabled_region, + test_write_of_access_disabled_region_with_page_already_mapped, test_kernel_write_of_access_disabled_region, test_kernel_write_of_write_disabled_region, test_kernel_gup_of_access_disabled_region,