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: 10463091 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 0B0A6603EE for ; Thu, 14 Jun 2018 00:47:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFAE128988 for ; Thu, 14 Jun 2018 00:47:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E427228BA8; Thu, 14 Jun 2018 00:47:33 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E8DE28988 for ; Thu, 14 Jun 2018 00:47:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936005AbeFNArc (ORCPT ); Wed, 13 Jun 2018 20:47:32 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:46937 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935982AbeFNAr0 (ORCPT ); Wed, 13 Jun 2018 20:47:26 -0400 Received: by mail-qk0-f196.google.com with SMTP id k86-v6so2681148qkh.13; Wed, 13 Jun 2018 17:47:26 -0700 (PDT) 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-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=zzWUcYaAx3ymXQzetDNF6sp6hqYFLThITRR3DMRzHoI=; b=AWw6HWsPIcR1pIXJq/x3gO9/WokRfNSrMgKmVWmTMtMQG20uowglspA9RJ/H3Q2OW9 R7anomxYRQs+qZ9N4EnzVGJ8Ur8+nK0pz2P5fjmPP7gflgraG2YNC4uZQ7skofhgjpAk g8YWN53C1TTb5ydDEn2daVrJ5og4gK95ljT4jPt4yMW8wBHbhbTew1Dki7w3cRLyYEny VBVMHQ7G2LfciMMhYptzrWRAPcLMToNppDGAmJrBtBiCxKy/z43PrzR4Iun4Zr1iAWnd +gGWER7q5InU0Tqk15xXvkDfMnJSHJdkfOBICOOBOd1rfuOIRPxT6E5cAmuv9MY1byi6 QDRA== X-Gm-Message-State: APt69E3AE5Hj934gnxn1LI3oZHDD4WYfEC1Q6mQNHGCipmMaGeG/Je0o +TtDoFEXETUg2JBlvopmhPw= 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> Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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,