Received: by 10.223.176.46 with SMTP id f43csp3256908wra; Mon, 22 Jan 2018 10:56:07 -0800 (PST) X-Google-Smtp-Source: AH8x227btbXRDOmOI7kb5j5bCowaS4UcBimk//t8ggkK502NQaCtblQxeugt8AWuOvNzlv1P0ldd X-Received: by 10.36.82.71 with SMTP id d68mr9587254itb.142.1516647367455; Mon, 22 Jan 2018 10:56:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516647367; cv=none; d=google.com; s=arc-20160816; b=FlTYLolHUBGZR2IOYm8AZy9FwvnzZYVaIcXIfiGi7a9vVofMzF3CEgL7QKFniZ7JcQ xzxo9tbGTWkYkeTwnseXyBf4L96YAqfClEAlabDETDER62uwltXKxoA7LZP33hFJorJD +xw2DyM8ZefFAS1U+4PIFTeBe18d6P6kgGrzuNzP2YP2S92Uv0Dd4528YUm1AZTeQt8K QS1SUtZpmgnxALCpMdId5vZL/Yh5XSUAWfnCV8E4/PQhQO+GNBz7xwvraMPpMoQPXoZ5 +oMim/dYZhjr9fujHliv8P+mV3BIlPoMviEKynsIS9RWqJCWwadeT19a43ar6K0LLxus B2uw== 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=7GE7udgf3ARsnKL6b72AQGSi9JyoQDYRtRaYQ06/hVc=; b=MPmVXT/9dZBwwnNASi01kI9RM3YA+Gg88FD7wPy5WNpu86ggVsUb0hPYuSqb6wMaQs HXGBN/Jf4aJsE7oiKbJKGqMiltlOKkuyZvFia92RDy555PiiC06o3ybkd9bLpCb7PRut 3P35T1WorUvR+ffJobDtOtYezl4XbleSi8wc7Qtb8aotpDWQ+D+NMkf4ZoPjYUI8Q8La 421BkKOZzVbvDMb0WHe7Fa1Hgh7UaCU2vtkw39lMPFOa5sP1N7L7ySGjOu4agDWYdSQZ c3xcq9XvicY+fEzNqnVSZv6GbbMA/a+b2/q8nZ4hwALetjrZ7Za+MrTzXq9NHUr51ppI R2cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=LzYKyao2; 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 p42si13200331ioi.340.2018.01.22.10.55.54; Mon, 22 Jan 2018 10:56:07 -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=LzYKyao2; 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 S1751562AbeAVSxt (ORCPT + 99 others); Mon, 22 Jan 2018 13:53:49 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:37054 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751459AbeAVSxq (ORCPT ); Mon, 22 Jan 2018 13:53:46 -0500 Received: by mail-qt0-f196.google.com with SMTP id d54so23492142qtd.4; Mon, 22 Jan 2018 10:53:45 -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=7GE7udgf3ARsnKL6b72AQGSi9JyoQDYRtRaYQ06/hVc=; b=LzYKyao2iDGaRhFPQSyaMuFY+iKpovWLxgJYEXeMO2MGb6GmLllz5/7jFPPi1qpjhC 7MVrsQ6YwnipJp2Xg0ku12SaCMzVx5cBbVcCLcWIhHmPmIpsi5K/ZnjlGmG4QyzfQXqi Ct1SYT6KeYKmWjx+XjcfvCR8lK5ffSiqcBoxAPsdQpf4GXxutNA7/hR0E3jdHavVsN1r 8EBoE1YDfZom5OnqA7nZhs3b0l7ezSgNRCRWfr2oKJ2yoCyKtjqlZq99A4OVG209zMlY 3+Ppliu7dg7CXJSxkCsjIh73nKON4Gkds/e7Xw2dGBOIXYwSKwBYcG5PJ1BKOnAthwqJ thzw== 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=7GE7udgf3ARsnKL6b72AQGSi9JyoQDYRtRaYQ06/hVc=; b=JApjFugg/gwm8WCdGn/p0/2+Uulo7PsyQnVDW6mpHicOdMb4MlnFCzzCHThDjbbG6y /z9RVTXdugvaSp2iBwzxH+7q1i//xUdnBX4wIpSK0a9iAvoSBST/cFJyXuDkP9WMjBid n6ixnhun0Q2wpp78LMkI7gE+c6vpUrC26UmxNo2qMBqW8yvUKA0Ol+zoU/OwQcn45Ejg wvklzg8HGbhB9jCXykGza5gYJjlAiVNkf2qWyq79yMzQb20IrFhrlD1YomAnkihgkHI9 vpR1cphbj5fbNhMzdcB1YO7asbNhjiELPXIyllKgLVaS/0CiXgDRettzzUzpV3Nz1Mu7 AIVA== X-Gm-Message-State: AKwxytdpMC1ONac+ANmMTjRUMdACmeSVrDDz4ErveOhElvfR4isdQciX bPtt6D5m1jXNkpJTclwTJTM= X-Received: by 10.200.41.6 with SMTP id y6mr3579293qty.322.1516647225364; Mon, 22 Jan 2018 10:53:45 -0800 (PST) Received: from localhost.localdomain (50-39-100-161.bvtn.or.frontiernet.net. [50.39.100.161]) by smtp.gmail.com with ESMTPSA id o20sm10790061qkl.14.2018.01.22.10.53.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 10:53:44 -0800 (PST) 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, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, akpm@linux-foundation.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, arnd@arndb.de Subject: [PATCH v10 19/24] selftests/vm: detect write violation on a mapped access-denied-key page Date: Mon, 22 Jan 2018 10:52:12 -0800 Message-Id: <1516647137-11174-20-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1516647137-11174-1-git-send-email-linuxram@us.ibm.com> References: <1516647137-11174-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 access-disabled key is associated much after the page is mapped. Signed-off-by: Ram Pai --- 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 f90a8b6..3e9e36d 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1059,6 +1059,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; @@ -1343,6 +1355,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, -- 1.7.1