From patchwork Sun Jul 16 03:57:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 789053 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x9Fkl6XHjz9s3w for ; Sun, 16 Jul 2017 15:45:19 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LCsknSXc"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3x9Fkl57rkzDr9V for ; Sun, 16 Jul 2017 15:45:19 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LCsknSXc"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-qk0-x242.google.com (mail-qk0-x242.google.com [IPv6:2607:f8b0:400d:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3x9CPm6SGCzDqmL for ; Sun, 16 Jul 2017 14:00:28 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LCsknSXc"; dkim-atps=neutral Received: by mail-qk0-x242.google.com with SMTP id q66so17065763qki.1 for ; Sat, 15 Jul 2017 21:00:28 -0700 (PDT) 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=JANpNWADsnobl3dNwChC2iC2khk965WeVxmYGWTu4Mk=; b=LCsknSXcaUSk78iFQChgFqC5bfYAGIXhgMWjxUV/zHzDwpNACDHyRuhhEsoKryonks najFC2HXbq88SJfO2YuZzNVAjqP0aqoh/03KxcGnJrcQOqpi87FCxTbiNRrZeG+f1Xiv /UEFeTCdga4RV8EbAVHk5hYCKGuRt+3xwz9m3iVHsqhi33qovZY1CIxcJ/QBoEF9qWW0 T/gHZrlr7jiHU+z9EcZb2NnzFmRZKLG1QZt6N/z/YYGwWYwI4XwKQ+RkVpy0U2SPOFZw 397cXJhTs1pRuZJFFoQynZ0XhwFhhjy2WYBFrAkZpvjaqE0yyf90V9tPdZVCsldJJaa+ uOlg== 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=JANpNWADsnobl3dNwChC2iC2khk965WeVxmYGWTu4Mk=; b=WTR+4IV8q35YM6w5P7BhltyoPRdG8eqEj6AkmymOkDya9CbFBFrX90lsRo1G3iLxds cpcTwMRaDku82Cvv1zxhdDCAybZOAu6tQ9LX/N85TPdThkdpx0tuyZHaYDTBmr8qn+qO 8DM0vylHWsvEmDC7ZEkUm9JsPn9vowaHm/QnKWLst5RNk8kEzytC+MYQIFWoEz9tl7eo BP7D70rJl3X6g3MM+gjdigTlrHUrizeyuGL0f/yCq/3NRjhAmp0W/6lDgV669z3D1zIg OL8/uk6IFGSgCs1fYyLnLMIrnavt6sJMdqBa048NC+pYa538HjxFgfTuC7vbwrKiYKQ+ O1cQ== X-Gm-Message-State: AIVw113OsQ8g5AGIgvaM5AzUXtn5+OSJb4VM7IuMjHh1Zzr2M6/bDGg4 WyrJkZf3w1koraD8myc= X-Received: by 10.55.191.66 with SMTP id p63mr19304624qkf.212.1500177626014; Sat, 15 Jul 2017 21:00:26 -0700 (PDT) Received: from localhost.localdomain (50-39-103-96.bvtn.or.frontiernet.net. [50.39.103.96]) by smtp.gmail.com with ESMTPSA id q46sm2290345qtc.54.2017.07.15.21.00.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Jul 2017 21:00:25 -0700 (PDT) From: Ram Pai To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [RFC v6 58/62] selftest/vm: detect no write key-violation on a freed key Date: Sat, 15 Jul 2017 20:57:00 -0700 Message-Id: <1500177424-13695-59-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1500177424-13695-1-git-send-email-linuxram@us.ibm.com> References: <1500177424-13695-1-git-send-email-linuxram@us.ibm.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: arnd@arndb.de, corbet@lwn.net, linuxram@us.ibm.com, mhocko@kernel.org, dave.hansen@intel.com, mingo@redhat.com, paulus@samba.org, aneesh.kumar@linux.vnet.ibm.com, akpm@linux-foundation.org, khandual@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" a write-denied key should not trigger any key violation after the key has been freed. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index e35cef5..07df8cf 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1068,6 +1068,23 @@ void test_write_of_write_disabled_region(int *ptr, u16 pkey) *ptr = __LINE__; expected_pkey_fault(pkey); } + +void test_write_of_write_disabled_but_freed_key_region(int *ptr, u16 pkey) +{ + dprintf1("disabling write access to PKEY[%02d], doing write\n", pkey); + *ptr = __LINE__; + do_not_expect_pkey_fault(); + + pkey_write_deny(pkey); + *ptr = __LINE__; + expected_pkey_fault(pkey); + + pkey_write_deny(pkey); + sys_pkey_free(pkey); + *ptr = __LINE__; + do_not_expect_pkey_fault(); +} + void test_write_of_access_disabled_region(int *ptr, u16 pkey) { dprintf1("disabling access to PKEY[%02d], doing write\n", pkey); @@ -1370,6 +1387,7 @@ void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey) test_pkey_syscalls_bad_args, test_pkey_alloc_exhaust, test_read_of_access_disabled_but_freed_key_region, + test_write_of_write_disabled_but_freed_key_region, }; void run_tests_once(void)