From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227H0eb4SeanM8WYzrxo3NZlMosLnumhSOCRAqWFMnISmmdLMGvvnHI/tTqPtTQMOAaZun8S ARC-Seal: i=1; a=rsa-sha256; t=1516647319; cv=none; d=google.com; s=arc-20160816; b=RGGMFAiT/U1LvHihzO5C4hYE7XqcjjKSdXr8lStlkjeZiOBKrfDNMa1Bxvu2QkG0qr EjcRWUvifgeF865lfVT0NHZQL96+9DhAvLFeYbnxDGsEcm7P2ocJx5lRXC6hjjXw/TKg TmulIbZz2G4lgTLWSsPOl/DErQrE92u576cAlkVkbSl0/4+neoRerjjHHjLInI/w/50O HZiaYCsk1do9bUteBmfhcO5PyyILZ5m3rhYRhGLsr05X7fPMUy5yV+pTaWp4s5Vtdvrw KbGINdjuEvjVCke0BqxFbE8GFjKBLxRjgnk3mWdTV8F1fzzB0Q7QEvDFGx7+xf3w086Z USuA== 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=0zfOUj5aoyQlgjxRV9mZHMrnH/x/I483lbUiMccmLEw=; b=FGbWYfiMKyRdrGUEnFc1stlfsaU/g5xjjM/4E1VqpaCA+3YA+Oxz0IjJRzqldhm/Hf l2apW9jxJw6gZpK/vRNAEgJr3q18tvhuwawya5mLpWeNru62EWOuhMg9+yIDwVcdhFCL m3CpdPs4FJB06HVgKRLZwL1fToTdonZguuZa9RP2W7XSZRtzpwRUjYxismmzqHp7WNvD n8TxYVIs/Z/TAZpiHLbLDCbGymBr5navlIiEe/bmGmmRYnXEFOhKxeDkH9CkYTMLJnYk X4okQkImDpRRRyuNof+rHfPRki4e98W/I3j3BJiRbxafBZzLsQ7NwYbPIyo/G11ifC0F GY8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=LzYKyao2; spf=pass (google.com: best guess record for domain of linux-kselftest-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kselftest-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=LzYKyao2; spf=pass (google.com: best guess record for domain of linux-kselftest-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kselftest-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 S1751547AbeAVSxt (ORCPT ); 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 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-kselftest-owner@vger.kernel.org X-Mailing-List: linux-kselftest@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590319979854435226?= X-GMAIL-MSGID: =?utf-8?q?1590319979854435226?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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