Received: by 10.223.176.46 with SMTP id f43csp3258436wra; Mon, 22 Jan 2018 10:58:00 -0800 (PST) X-Google-Smtp-Source: AH8x227IFVYQ4mwyWxXM1f5VaA9K2Oq/LE5/U02RsTxmIdqQCs4JayxPgcVA/YzQGoCfY9qOmWI5 X-Received: by 10.107.97.18 with SMTP id v18mr9107229iob.7.1516647480057; Mon, 22 Jan 2018 10:58:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516647480; cv=none; d=google.com; s=arc-20160816; b=vTRyrjZagVDA1/dHmETVRVpzlpwiD0v8XlBlO8VhWNgOBlEQ5p/TCbdZOZvSVod06Z EJpiaAiFCLVZPFhD342fgAqbtxV80015tImRWfz04xxh9ClV5tJJIppRsdl218nl+Ywp tFCLRIF37KQd19QvXNfvjVwJ8voYo6ipHGNVYQz16+wN1f+0U54rq9lrgDDWuBGM83rl Kd888Y7vh8VYev9rqYVPxz0QqnSCpUrxlLTFqs6vAMAABL807TRNG486QJztHGB8Tk44 1q05yxORFrnnmmkD7LxpodOOknjn25arSqZbQUps/wxb7kBZ5q1Rerhe34OiUH+refQq 2rKA== 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=0ImWq4P6HbCkvDuKoQtR4yQKU3F1puNdyNS8m6yaVGQ=; b=TgbypuhPnYf46nbd3wxe1iJhm9EN6EvVP+QnTY09u2iP4JLaIw4ZawtIPZXZbjLnAj WG5VRJ2jsT0UKcRifwhj0WqOBPqjqbH3sFV1XSxrjwFWdQZ96GSgV9MksvIMltB9kueN Ej0vNRtbsKqWpZuAZ9qwakRaO6flm23MA902tmFIep2oEWogv+wvsS+0b91iPbnJ6nXl kagv8F52m+iVtnnY2Dl3zm/tS0lBA0dXLVoq1tao+hhnJ+ihsvYWJoarL+oFtCLKNIBF wH8LUR6ymMVYgxNAUVsuc0vbLcR5dZIVJyZpwjG0/WbBIBCbrt7OJgKjtwiJl8kz/HfG 4fDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=rsYgzGnN; 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 j42si13649829iod.69.2018.01.22.10.57.47; Mon, 22 Jan 2018 10:58:00 -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=rsYgzGnN; 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 S1751821AbeAVSz4 (ORCPT + 99 others); Mon, 22 Jan 2018 13:55:56 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:33833 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751506AbeAVSxn (ORCPT ); Mon, 22 Jan 2018 13:53:43 -0500 Received: by mail-qt0-f195.google.com with SMTP id a27so10309598qtd.1; Mon, 22 Jan 2018 10:53:43 -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=0ImWq4P6HbCkvDuKoQtR4yQKU3F1puNdyNS8m6yaVGQ=; b=rsYgzGnNbaK2Mva/GNtVpytqdjYy2SkaMzs11MqSkqcM79IcO968GNsmV493Pt2FsQ gherdeEihNY/WfOYyzuDWPLwGnUgkQjLFpBzCxY25Br3k/fNZXhZqUOpCagFF2m0EJ5M mpM6SsdMdzwlU5eelq9+8K4DElYkkN/piBTMAN4oJLXCf8p5rlRX+IXhSi+TEtc1FlM5 iKpkcBSNuSGWkzL/x4hY3oaaukhCmMDcyRsg+fMX2mmWjZoAhW6bbb5xsKscWJJSLTuP NnelWr4no6eFCMZl1VQiPrCPeeNovignLkLPIhECi0bNT8k7Kb/EfdKihnoS/kE3oJOV KRuw== 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=0ImWq4P6HbCkvDuKoQtR4yQKU3F1puNdyNS8m6yaVGQ=; b=RJMf6j/sClW+RqQgam7hu5tpttbJnUicbtfY1totgqXA/LYv9koQnZmee10NOfa0Q/ V/oa0NfaJaXXCrhr0ik6IBNoeFweR8i40kDmV7AJYsOxOuHqQhkkCVtI4qYMkSQMgeLL 8slpP2BLF7sQvC+kGB7aRpTGKIpFHicQ1wZt44WLW/qVYEPXArwJD+emUFCHA8H7LgAb yzocJW6Rh2/z0oKv0ZB/ylmhybi1UXb/IEG+c9bcHEThKMn+B+GpnpxtrVGO6VnG03V9 hulCP+IvCan7ZdYmpYNbU6wlX4t6ETOiSi03IpacWb3EmVNYBCJVXQGze0ICjKGDGJpC ONPQ== X-Gm-Message-State: AKwxytfzCUUKds09RKhe4LeVywnX9oNXR2PbY6IGfxWwIi+BWZYwnV/N DFFGItg3R0LwegyyzKgfmyI= X-Received: by 10.55.76.17 with SMTP id z17mr11964203qka.145.1516647222635; Mon, 22 Jan 2018 10:53:42 -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.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 10:53:42 -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 18/24] selftests/vm: associate key on a mapped page and detect write violation Date: Mon, 22 Jan 2018 10:52:11 -0800 Message-Id: <1516647137-11174-19-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 write-disabled key is associated much after the page is mapped. 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 1d3f596..f90a8b6 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