Received: by 10.223.185.116 with SMTP id b49csp1379668wrg; Wed, 21 Feb 2018 17:59:12 -0800 (PST) X-Google-Smtp-Source: AH8x227beJi3S1UDuS2zP3KgpgTmB9lssrwy+D/wbPQBHgwJeMaRQzkWkdIWH1PtX7/tEKZfngDp X-Received: by 10.99.121.131 with SMTP id u125mr4304771pgc.263.1519264752063; Wed, 21 Feb 2018 17:59:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519264752; cv=none; d=google.com; s=arc-20160816; b=huHdPn6OtEXwjX+mQZrbGIU/yQrrgm5ounxzee6kJswZvlc5vEbL0+os0hljkm9WMA 2M7XUnqaWaVEWkCe9JhdzSdwtIlOzecAsdbbPyxOUT1vcwJViyIsjdQ/YvkdPBL/g27r GWYTIMykAJUqfDCffAKpepnwHGQOdkwSXf1fP8kdkx5Fato4DKaGYMcOb1THN3FOINjK lUL+XgBVUMlPGNr4sZtRd0BoVbSwH8hvS53ZGXjyYOCTOepk3bdHeaOekWR5i6nPppDU Md9U9lvtz67b0AWUaZbKN0+KfWURrF4vc1cG7kp3G1qVvap0RQ0OVBT/Ec9g2EhjMzrD +GDQ== 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=i9I9cr163FW+MkxRQeyoUEt7s9XC2JsdOREeo31p3R8=; b=kBZDOtKa67SDZKT3TgKBheHE8RzJW2nPYMl21leU3vBhOK0+XBrY/NX9DA7u1CQxrM Dv9FqxykWufzLKLLP7XwAnp4RHiidHYOkJ0kyOAtPcjckkqMD1KqzIOymG8MpbK9hngV dQ2CoMtL6z81V231ldVxidHOtBsIn5O3Xk7FPsM38GkwSDY+uY7go8CXtYK3HB8w2/oc emC/E6rHHCaU7adasCoQ1Yaa99Ftff25/7VKC2BQ2iE3QGZy51eR8VmaXq3lBC+KLvCN 9nlK1FQTVlsTdr6hxSzsbCriv+vXkQelmhSx/XezvxfGA5hkgM49MVdR44kU3XBNspca JTjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ue6/fR/t; 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 m7-v6si779844pln.711.2018.02.21.17.58.57; Wed, 21 Feb 2018 17:59:12 -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=ue6/fR/t; 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 S1752200AbeBVB51 (ORCPT + 99 others); Wed, 21 Feb 2018 20:57:27 -0500 Received: from mail-qk0-f196.google.com ([209.85.220.196]:37421 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751833AbeBVB5X (ORCPT ); Wed, 21 Feb 2018 20:57:23 -0500 Received: by mail-qk0-f196.google.com with SMTP id y137so4629286qka.4; Wed, 21 Feb 2018 17:57:23 -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=i9I9cr163FW+MkxRQeyoUEt7s9XC2JsdOREeo31p3R8=; b=ue6/fR/thxq4ZY+V/ck2qQYq9CMhtUJlINqoLOEkLStH86UekrSDSqc9Urn5wStsgA cdr6tpIoXCmW3MMvHF/Wb57AVO3lYFz+PfUbky2Ps2Hp2T0ZLvSn1KXgVYWdnQrtHrAH etibJk/RxHk3JfqDRsQVvcnuHs5TBXRhgOnuZTrHS9ICSnR+RHWS+Ug8v6QGU1TPOWh2 nXKIDztOHcpetuAOYIwqiQHNDQWo86CYcVlSIVwsBHChtiCzqTNgw+FWUMpCgmMmfuTy HPzKIkszAR7Z3klncmu5swRy+SE50THnRZ5JcXMevipwlqP66O+1Reitb0JK8JxELgjl XEUQ== 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=i9I9cr163FW+MkxRQeyoUEt7s9XC2JsdOREeo31p3R8=; b=pSFHbodU0pJ5FQF3qyPPLMOSClrFEXE5UFwzX9r2r+O2WUjzZwVeLd+3m+sEaQQVZu iK6w8WxzAMV9plTdWwq2XzV0wUNRpzzjQoFeTDSwQQ4GByfXYRuGg/cVIOcJRWbHNRDi JRg6qa25q5vbguz8RP+yFsZ2zEzk07PAdzuMq74b3pZOCJiYAOMo1dvkwV0YBQX7c9z0 wHZcrm/H97CY/SV+TL9eN8RGd75+JjhGNwEJ7GA7IJ2D6HCKujSyhHviMh69/3KmTfNi Y0OeWAffzkVJeg9jrMWWVBUku5kUnwu6XmZhVO0H7tkjx9iSTU7+9S3JSQ/heKUrp+w1 pJJQ== X-Gm-Message-State: APf1xPCund6GuOrgi62XXP/qWNn1k9u/okY2GAw/OrDf/667KPvNvmd4 fY8Bry7in65meExUB/toKHkocjNG X-Received: by 10.55.7.131 with SMTP id 125mr8037911qkh.171.1519264642759; Wed, 21 Feb 2018 17:57:22 -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 n29sm14182630qtf.18.2018.02.21.17.57.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 17:57:22 -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 v12 19/22] selftests/vm: detect write violation on a mapped access-denied-key page Date: Wed, 21 Feb 2018 17:55:38 -0800 Message-Id: <1519264541-7621-20-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1519264541-7621-1-git-send-email-linuxram@us.ibm.com> References: <1519264541-7621-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. cc: Dave Hansen cc: Florian Weimer 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 b685e26..437ee74 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