Received: by 10.223.185.116 with SMTP id b49csp1380483wrg; Wed, 21 Feb 2018 18:00:20 -0800 (PST) X-Google-Smtp-Source: AH8x226oeRDI6bLgKKb2HjRWdzChCMvrgD0tA9yGuVRdsnQ0hetaufb3Rqftwq8Uwp3KV7CsOCg5 X-Received: by 10.98.245.18 with SMTP id n18mr5096046pfh.25.1519264820665; Wed, 21 Feb 2018 18:00:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519264820; cv=none; d=google.com; s=arc-20160816; b=IqwPVJjpGenXz++CMEKr6K8baGgbOASdEWkFtIBndEx2h7nh9UWt1ohMequT8Mxoc0 KpDwbpHUxh/MA3MLsd1zYfhS0xc2v6td7CcniPSpA0bEmwtCZl9r5omlzJ8DvnC8xnS+ TQLRIybwmVQo1v5p/9WVrPFElDBS/rUWGTE/DEFnZI54mrDb2YgreWruW/15ja5jo3Gd wCApVXQwmFi+xh3ItLQuUdXPGXTYU4oSZI+RUu4hO/K/8OaF1WVUZJHCxFqs3QrB7QJD kmhfL3JANB9yDKjvvx/LC0aHrdui5X76nEJtcxRq+u4LMYsAJlFKKiH/YEDZbqjkN7oo Nhuw== 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=o+9oVKCfodDRCohtQow6ggE9hQ+vPRHsrLlI7Ww33k0=; b=zAqSHZXUWHGYtLSkS7hnlm/zPZgMU7IU1wGCvlBqB5ynd9BhEj3OGVjty9HN2vAcMe Q0Wii2Wj9Nk3/1izzlAjms4kYkHQrtTplaQVjlHd6hOLnAf9kVyeEdvJ8mkNsnqWSgCx wrbX07rl1Rw1z7r1VWDC07IpBQb7sVdAtgNGnybPo3O70GM9vWvY3G59+tUb6uOu7nV+ u6ZFCunXW0PEKNRgYIBArlIhyYvJaBVzbbciid9zuw0lpW2JLELctVN83Ohmu1MGLgac P73prHShNgK2S15G1EB88KmaJJ9paS91C7hHBojFO3u4duen1/P/X7Qt1ewFO5evi0DR 9Gzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=nyGi6HU6; 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.18.00.06; Wed, 21 Feb 2018 18:00:20 -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=nyGi6HU6; 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 S1752367AbeBVB6h (ORCPT + 99 others); Wed, 21 Feb 2018 20:58:37 -0500 Received: from mail-qk0-f195.google.com ([209.85.220.195]:44258 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751841AbeBVB5U (ORCPT ); Wed, 21 Feb 2018 20:57:20 -0500 Received: by mail-qk0-f195.google.com with SMTP id v124so4612811qkh.11; Wed, 21 Feb 2018 17:57:20 -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=o+9oVKCfodDRCohtQow6ggE9hQ+vPRHsrLlI7Ww33k0=; b=nyGi6HU6Vn0HkROoxCfLDaPEt1GSqOdgRNx+S4Aea/JUDEOcpBTFAmdFXwQb6VMWqw eYc4tTSn2ZMACanwDPkl3O43sk80SwEpoXba6XI1uyrOureI4zDu44sqjdOnRn9D2Hu6 5xnqjT6GIy7ibd6nj9nllssdL3jzkh4+fw3fFA/+L1kuFjFyGStl/DlK8xRuVqaAwtBq 2aZEGXDlllISjSMhTaPjV8spVh0hDcGVVevDB6i7QFi85bK0Edn2i7NeVY7w2kdTG2pG 729iEculcWlOzwGSPHsj3mOEQMYD+aArJKCyNA+p0tOJBcYr4zOHQ1w2LSh86fHDNPp6 ppXw== 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=o+9oVKCfodDRCohtQow6ggE9hQ+vPRHsrLlI7Ww33k0=; b=Z9xeU27BwkWKwbK7NdPJUrTyp/5Xt1zsFP0AEs6yvoemTS55DvSGbZSyP0rIF7XCkq F7TGzjLnZrBlMxF9t92r56OXWwyPnWKCdgyg9FwljmzC7DheEBSyE2Y9n/csB1egwUVp oL/OjdN1FYq358ELZJDOxneoK2h3eNyBDVFZFzSqRKZUNOETihMEmynlk7Q0FUIG1/oJ lnOmwdklrdINaeGLbJHr+myBCPZquYDQTc5VFL/ZcwvFZKjPRqAF5d0GkuEkVRqVsc0h gsDmtMAGFY9OBjb79o5kgdxLVs6PsYhNyqKLgMeszrddmfpGKV9rpT5PKFAKGr44oEz9 o5Gw== X-Gm-Message-State: APf1xPDU4cht0vDv1cD8HM+DVV1r5eWvp1x4v6JEsqeOVKAUP3sPYP7K XqZW5L4HSHKpUE1fGdOm8iEAzuvj X-Received: by 10.55.25.150 with SMTP id 22mr8411269qkz.183.1519264639902; Wed, 21 Feb 2018 17:57:19 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 17:57:19 -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 18/22] selftests/vm: associate key on a mapped page and detect write violation Date: Wed, 21 Feb 2018 17:55:37 -0800 Message-Id: <1519264541-7621-19-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 write-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 | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index dba9162..b685e26 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1034,6 +1034,17 @@ void test_read_of_access_disabled_region_with_page_already_mapped(int *ptr, expected_pkey_fault(pkey); } +void test_write_of_write_disabled_region_with_page_already_mapped(int *ptr, + u16 pkey) +{ + *ptr = __LINE__; + dprintf1("disabling write access; after accessing the page, " + "to PKEY[%02d], doing write\n", pkey); + pkey_write_deny(pkey); + *ptr = __LINE__; + expected_pkey_fault(pkey); +} + void test_write_of_write_disabled_region(int *ptr, u16 pkey) { dprintf1("disabling write access to PKEY[%02d], doing write\n", pkey); @@ -1330,6 +1341,7 @@ void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey) test_read_of_access_disabled_region, test_read_of_access_disabled_region_with_page_already_mapped, test_write_of_write_disabled_region, + test_write_of_write_disabled_region_with_page_already_mapped, test_write_of_access_disabled_region, test_kernel_write_of_access_disabled_region, test_kernel_write_of_write_disabled_region, -- 1.7.1