From patchwork Tue Jul 17 13:49:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 10529529 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 756E06020A for ; Tue, 17 Jul 2018 13:51:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A56629203 for ; Tue, 17 Jul 2018 13:51:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D3CF29221; Tue, 17 Jul 2018 13:51:27 +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 E08EB29203 for ; Tue, 17 Jul 2018 13:51:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BA2D6B027B; Tue, 17 Jul 2018 09:50:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 03F9E6B027C; Tue, 17 Jul 2018 09:50:44 -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 D8A8A6B027D; Tue, 17 Jul 2018 09:50:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f200.google.com (mail-qt0-f200.google.com [209.85.216.200]) by kanga.kvack.org (Postfix) with ESMTP id A29136B027B for ; Tue, 17 Jul 2018 09:50:44 -0400 (EDT) Received: by mail-qt0-f200.google.com with SMTP id d18-v6so741864qtj.20 for ; Tue, 17 Jul 2018 06:50:44 -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=Q1R31nux8haGsKepcZhzzzbKTonrVf6YCtKX7LZHbRA=; b=iPkq9dBgaxFjcq7x3aVx3RHVFld7TFzjZiQYFgzeW9/cmwxk0X10hAiOYooqmCMrRw Aerh1GqITJx53fr6Ee6fcDYd/L847tKC/FhEhwkJBVXCw3t7rGCbMhC9TRewulx8Pwjo nMX9sGsYGB+f1C4/KOmXf8vuAq18m4yZIN22gctoYl4ryqBFlP82ma+oP9JGj8PwdKJ6 bVGqMicOu0Y4bEx8ChjBvu94UGPP6Xw6yqS0PSKENdQNphNwXTp5cxu97ALz0uUMwstS en1liCjH1vWx+fUvfqQykEeT/pnoo5vnxL/eQ9NKWIkhJQgtkqGa5fP7tUbuILqkw1jU m79Q== X-Gm-Message-State: AOUpUlF3xxcZixxwiAGJpzz97va/jNuLByCya1IobHC0xdTrE3rtNxcd rl+nCXGL3osClizrOSxFSg+SyVV7lmC/GbGCyH+HoVryTMI/JjFaGjCPv0Bl9OjjjDsb6zuDdyn +TDzThVgYs/j3XvM8Hjij5z9NwFXHpQV7IIGHMUK20vlNexzmwCAsTrdFjtcyooCJq7lW8Q8abd yLPyOsPCuGDQShefxAURzDIztnBeWv351INP7cYavbx7lOHiFPmbQN6MKqDDfcuQdTMh9e2ZrLk yqR2qcxbkXeyKphgZH8xooNkKkPa4yTrZ3e+P4IoLaSYU8VLLR01dyWNVMYUgKpbODFIbpNvrn9 82eLBAkTkUSOVbEo4SDNI2U9BbVm5HpM+axkRhUSwlFpeARSncCHUG996KxdXVOkvXBK85vJaA= = X-Received: by 2002:ac8:31d0:: with SMTP id i16-v6mr1625648qte.12.1531835444456; Tue, 17 Jul 2018 06:50:44 -0700 (PDT) X-Received: by 2002:ac8:31d0:: with SMTP id i16-v6mr1625590qte.12.1531835443612; Tue, 17 Jul 2018 06:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531835443; cv=none; d=google.com; s=arc-20160816; b=VJ2K7Z3vj6USIwA8fLJL5zhO+Fk9mbRpOeK4DZ2DANVDf01KF6ikvpce1gmZhEYc41 rFPiy1S7++nRoQxzTHyahbLcfcTEsYtjLnXPMJN5ocgGwfXxiDV0dL15AwIf3T9IW4Yp jDsikebhG/jtMJQvqUSI/vB2l4wy2zvatbBL19OGD4/MvBkdDDtH4VOnsNyU6PqCNomJ mAKeg1T+XJ1x7wEqGjeeYEaOThDHR7RNBmmzChCvFO/uWV3jERWxSa9rMU3pcOjqSkFq ek7PE0wjS+nQO4EMakC4p2lKEhdPMvRxFVhDYap+D4Nfk2VzvjrZMov6syfHriQvzyBT Jskg== 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=Q1R31nux8haGsKepcZhzzzbKTonrVf6YCtKX7LZHbRA=; b=Y3p93moF/B3xmBW3TGd4YZIfMhCUnrUx/b7P7wzOHENWnn/cajTyregPhtw729mTe3 m0gijpYmkzixJA4vjl4hyfkafb5sBG+4JfPK7bgvtkYRh1JVtKVJC5gcjUIgwNdhdNqh r42dD/sYuoX2Vu+ottpQlLJ+NyAPyNv1SMJqjPd5J6ftlO3XWuCaLV42q35cESiJ1fil 2BjSxTQ+N3lLYezIqQ7odgrUgHSBWia2Bj/WUC/2rSI0LhyZYAyA4WJuCADgqGkpZl5c gFBR13ft+q+mz0BkpG+XG+3OofvpVPU/un2OgLyR6HLcSH2NZhs9A//poR7oolIjXZd5 zA/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n3nvoFLe; 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 x20-v6sor489340qtp.124.2018.07.17.06.50.43 for (Google Transport Security); Tue, 17 Jul 2018 06:50:43 -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=n3nvoFLe; 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=Q1R31nux8haGsKepcZhzzzbKTonrVf6YCtKX7LZHbRA=; b=n3nvoFLeO0o3r0SWEc7kh0Fywer+EiST3sMheIciB+YNrPUUN68Po0taOiI83sMsdy avfgteeElusAhHDBTJAgchwLyir33HOX8YLL4SZzukltNsHH3EfdxYaqTgRLoMjc4TCh we2upxbtN3OYLGbECh87wukgeHIsRdeyU9Q68MNQZ202ooo+/EDjLRAy+MjppWCZiKy1 BCt2siKkyyr49wbsexpmIcBpilKwY/5olV4thzxuXs3PxhrURI7jq6vv5FuTcQAlJV2+ Iq8FNFhiejdG54yPfa+ry4O5hOcciGj/e0DW1Oo6zkKsfhfLy+jybjqvaANqNQtsVdYa VBLA== X-Google-Smtp-Source: AAOMgpfh0SDtpkSC3JkD24Jv9ye8NsQrGjChHnSqyCRzdyb7zvY7Z3YSFEDxKk8SPz5bDuK07VZ2LQ== X-Received: by 2002:aed:3c48:: with SMTP id u8-v6mr1656128qte.6.1531835443418; Tue, 17 Jul 2018 06:50:43 -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 s83-v6sm640937qki.20.2018.07.17.06.50.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jul 2018 06:50:42 -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 v14 19/22] selftests/vm: detect write violation on a mapped access-denied-key page Date: Tue, 17 Jul 2018 06:49:22 -0700 Message-Id: <1531835365-32387-20-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1531835365-32387-1-git-send-email-linuxram@us.ibm.com> References: <1531835365-32387-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 59f6f33..8a6afdd 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1063,6 +1063,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; @@ -1430,6 +1442,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,