From patchwork Tue Jul 17 13:49:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 945090 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 41VNZg4XVrz9rxs for ; Wed, 18 Jul 2018 00:53:47 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NsemcX54"; 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 41VNZg30Y7zF3Hg for ; Wed, 18 Jul 2018 00:53:47 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com 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="NsemcX54"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400d:c0d::242; helo=mail-qt0-x242.google.com; envelope-from=ram.n.pai@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NsemcX54"; dkim-atps=neutral Received: from mail-qt0-x242.google.com (mail-qt0-x242.google.com [IPv6:2607:f8b0:400d:c0d::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 41VM9t69TdzF3Hd for ; Tue, 17 Jul 2018 23:50:42 +1000 (AEST) Received: by mail-qt0-x242.google.com with SMTP id t5-v6so890619qtn.3 for ; Tue, 17 Jul 2018 06:50:42 -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=2r5cNzFLeSs/K5pqni8TxL9LDzfe8+AFTceAArQnt58=; b=NsemcX54Ab2eHV3gr3dGQEaZj5kaq4ANx8CQ/F3eCDHdWyrdUUJJDY9rAm0s87u9aH 8wE/0rCjA61HPxnRtz2oE9UixHydKdn0+sdqjuPP+Y4IamXiovGza9Msko7ZZIPgNVAB /1I+NtDRJ5DlxUV2TxWWcA+DnvlKRDhLr7y4XiG6/wuup9kvb2mu8dbJQqeoPVTOnIJ0 cZLqxohZ9ZyGxf3i/xye+z5OQM8Bdrd+jMdIGXUx6cezqSCscXgnU6Q60xl9ynb83G9O YfuENDAyis+LwF2Zuv7yyw9vzclRwxY0yFzZZQT6fScN/OPg54QHOVZEUYU0HMWVhpde zh6g== 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=2r5cNzFLeSs/K5pqni8TxL9LDzfe8+AFTceAArQnt58=; b=LDk3tdVvDokFd0c7634VAMTIDv3u0Fw7wQUhnrabtGay9xZpTvcD+6120zbDbxETWg AxIuF1imc5zSU6wMehZ/hmwHXuzJ6PLICrleVzUZDOKUwTJupqIGJ1GEbhVhji+kNIcB eCYYvWRl4jC57YDCeG6QqNq1ZZhi/6EDU7xXoGDhr9ThY/7JSMbFmVAlo5YZtw7aWq6e YP91Yx412ZeYKsKPZgyVELz4hP3XmtwJpnFJnKFjSqFbHbUyVvyKt47eqzdnL0OHu9Bj hcQl5aG+AIH6ADTgu8WCJ0hrNn3T/UK+gO5cM6mXJrAWYL72IybdPNexSp4uTG4CR+i3 f+fQ== X-Gm-Message-State: AOUpUlG8p+Ut8hMUjHmOuoTlgwdUR5Aj70qDWXnSwIrrsBOi5LmDCA4Y TtMmfEuGFKPTsvqt03bGpOOO8Q== X-Google-Smtp-Source: AAOMgpcwFK68KIESRKKvrTajlz7/8yINdJHTqveLX6QSygzfQxNLzunj3DidF94kEPz6jaFgughvEA== X-Received: by 2002:ac8:174a:: with SMTP id u10-v6mr1595982qtk.367.1531835441007; Tue, 17 Jul 2018 06:50:41 -0700 (PDT) Received: from localhost.localdomain (50-39-100-161.bvtn.or.frontiernet.net. [50.39.100.161]) by smtp.gmail.com with ESMTPSA id s83-v6sm640937qki.20.2018.07.17.06.50.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jul 2018 06:50:40 -0700 (PDT) From: Ram Pai To: shuahkh@osg.samsung.com, linux-kselftest@vger.kernel.org Subject: [PATCH v14 18/22] selftests/vm: associate key on a mapped page and detect write violation Date: Tue, 17 Jul 2018 06:49:21 -0700 Message-Id: <1531835365-32387-19-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1531835365-32387-1-git-send-email-linuxram@us.ibm.com> References: <1531835365-32387-1-git-send-email-linuxram@us.ibm.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, fweimer@redhat.com, dave.hansen@intel.com, x86@kernel.org, linuxram@us.ibm.com, mhocko@kernel.org, linux-mm@kvack.org, mingo@redhat.com, aneesh.kumar@linux.vnet.ibm.com, bauerman@linux.vnet.ibm.com, msuchanek@suse.de, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 Acked-by: Dave Hansen --- 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 d41b2dc..59f6f33 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1038,6 +1038,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); @@ -1417,6 +1428,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,