From patchwork Tue Jul 17 13:49:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 10529531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6B9C3600F4 for ; Tue, 17 Jul 2018 13:51:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 501CC2921E for ; Tue, 17 Jul 2018 13:51:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4426129225; Tue, 17 Jul 2018 13:51:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5F4C2921E for ; Tue, 17 Jul 2018 13:51:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE4C86B027C; Tue, 17 Jul 2018 09:50:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B3DC26B027D; Tue, 17 Jul 2018 09:50:46 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B7896B027E; Tue, 17 Jul 2018 09:50:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f198.google.com (mail-qk0-f198.google.com [209.85.220.198]) by kanga.kvack.org (Postfix) with ESMTP id 6C2786B027C for ; Tue, 17 Jul 2018 09:50:46 -0400 (EDT) Received: by mail-qk0-f198.google.com with SMTP id u68-v6so845437qku.5 for ; Tue, 17 Jul 2018 06:50:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:sender:from:to:cc:subject:date :message-id:in-reply-to:references; bh=tpjjVJNvXu8hAFs53oogeqRK2jibwNpfYB6tEGPZTag=; b=kSoNCPfgblwzcpMlfG2NLbfamilSZ1ONERbCgMnoKs5PAA8K0rGgsSeTxXcAn7NJgt ijuFp04/KCqMzRp8U4Mlz0xJLCTL+Xl7T0o9H3rJ3yoF9Syj9BlY6FeGvpUa3/Y46P15 oG7A+KRZXdvro7ZjGcb6I6tvBwg1Ljp4v9p5W6S/liBeIgIbVuBn5GCGEEbD50K7CVra hA0HXpA/KjIqhMpnY53jy2HN1xUjH63Iick/wlOWPYcadHcFCraE456RtgrDuMMNaD9B MTG17aMJtBPQVIbj8mnCqgEbYqie4yQJY1BDztKHvRKIwmmldeoEVNsD6p5/9JPeIV+m w7Iw== X-Gm-Message-State: AOUpUlEnXA5S8MMo5AbaPLoCiuI9UTIMqp0AdZLeU/M/PhDKqNCFqiuh kWp1oH9JZXVNDD1pKxsM4WC1HK7UDg314JgSbjbY/+SG+CtOoGjDAPTNUZrHTjmHDc8pVPTyn7D ZMi+pLVxSFJihg8xqMMKpOlxkaKc8/j/Xq0sMdq32o9blQjnIZA6/WOi08rexYDPhZD8cu6qqz9 Ta9ehhJzWVtf86uJfOd+XuA6IL4yNZbCzQpXjebbbi1SftJYfySIq79Ntm2/27bKsgki6C1mtVI Mzxjys0T+lH9Hfn5pjJtJKsvOvfdfChprwDMIBmMhtBvvuo314JjlukaL3bz2x6x0oF8MZpehmR td6192d9w6pVyq827ulONksJEhFB9DgwP877o9h6pPnbK9Dl0NHo6hUOzPneS1LbNHxIwsoGFg= = X-Received: by 2002:a37:ef0c:: with SMTP id j12-v6mr1534735qkk.241.1531835446224; Tue, 17 Jul 2018 06:50:46 -0700 (PDT) X-Received: by 2002:a37:ef0c:: with SMTP id j12-v6mr1534687qkk.241.1531835445611; Tue, 17 Jul 2018 06:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531835445; cv=none; d=google.com; s=arc-20160816; b=ixaT4ZDKVtdsFxNMPWcCjweHEmBCZeJTexq55dlXl2PYsXY7NxniRJ/PidKOJoxUVo DXrWEZpTOE+Ifpz4uX2D2KvHxR577UkIc7qUp884GungsyypMrL+Ju3ChC3WVsKv2zeN GyN46/SYbJvcv/xeRTsJ9YozjfoCkjq+bhSMnQs57Fbvxb162ip03S4s4mOmolFToBZc XFKbHW9do3D/ZBppVK3f+PErtw+/SF3FMQIJ3pmU2TECpIgoGvOWIpAZlPOj5KHt7UWP nghiDyOfBSazDODEFtlP8b+XTD34qjOsut2jL2QmYJ59rdgnRy4iBZly25DvHfi4l42D LWxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature:arc-authentication-results; bh=tpjjVJNvXu8hAFs53oogeqRK2jibwNpfYB6tEGPZTag=; b=J0rIl35wYlSL4qI4qHsW75cglMXIor1aOc7cdcumBKxft9niYdmYIA3es8NTU2cRYC /wURGtqmJ4TYgRZ+evW0ARJpkoVwm4PEweRrIu2FUDiDKREZJBhpYbAeaOVXS4fOuCBA P9Cew/w1N0IQTPdeu26VXHDPFA9P92xBpV+a0CpOTqBNbPFZx70kC+nKPfx0EhZXc9OH Jy+wU2CNHYaCCzrj8To4DOMRkXmg/X9uryGAoUue45srzpbIGagmmf5jjXedZKqaJqOj 0fGUIUXIt2YwWwXU9rVOs1hf8li4R8hKhPnRPK4Mbklj9V5uO5l8Kfs1ymPL8n7LZgYY Skjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GSDmSzI3; spf=pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ram.n.pai@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m3-v6sor489255qth.149.2018.07.17.06.50.45 for (Google Transport Security); Tue, 17 Jul 2018 06:50:45 -0700 (PDT) Received-SPF: pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GSDmSzI3; spf=pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ram.n.pai@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com 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=tpjjVJNvXu8hAFs53oogeqRK2jibwNpfYB6tEGPZTag=; b=GSDmSzI3LSUsihkTMGJdw7BoivmYZVl+6EH4mZudN4fhbxiXVXzuXnaMdVy9l5FTqn 8ByM0Eu035saI/yyEUa7g8Z68XeAom9N7PPB635RnnJNADjPzO/jZDLAcARPWPiHLiKt pIm3xhVlbpnITsQRlSAcrg51Jo4LOgXfgSiZ61T0Bwzneu3KMpoTkSaFjQu6tF93XJQx KiGqCvDis/UsZ/i0IjYaDL1KuvdCmLpzTOOCExhKCJKsII/SUktH8SOlvzABQCt6VGRR FHDxKKkDDtQbI5BLHGiZd5dkid0v7ODvx5Q2futDLg4J/ohPixMZxGCvmpaaSo5t6ucM xqzA== X-Google-Smtp-Source: AAOMgpc8qQlwBwBpBWP18wyX1W+sFWZ3V99TJpmYfW+jklKpdtk6MJisWsRHBo0wZVC+BYt/Pq8leA== X-Received: by 2002:ac8:f24:: with SMTP id e33-v6mr1626546qtk.301.1531835445428; Tue, 17 Jul 2018 06:50:45 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jul 2018 06:50:45 -0700 (PDT) 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, mingo@redhat.com, dave.hansen@intel.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, linuxram@us.ibm.com, fweimer@redhat.com, msuchanek@suse.de, aneesh.kumar@linux.vnet.ibm.com Subject: [PATCH v14 20/22] selftests/vm: testcases must restore pkey-permissions Date: Tue, 17 Jul 2018 06:49:23 -0700 Message-Id: <1531835365-32387-21-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-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Generally the signal handler restores the state of the pkey register before returning. However there are times when the read/write operation can legitamely fail without invoking the signal handler. Eg: A sys_read() operaton to a write-protected page should be disallowed. In such a case the state of the pkey register is not restored to its original state. Test cases may not remember to restoring the key register state. During cleanup generically restore the key permissions. cc: Dave Hansen cc: Florian Weimer Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index 8a6afdd..ea3cf04 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1476,8 +1476,13 @@ void run_tests_once(void) pkey_tests[test_nr](ptr, pkey); dprintf1("freeing test memory: %p\n", ptr); free_pkey_malloc(ptr); + + /* restore the permission on the key after use */ + pkey_access_allow(pkey); + pkey_write_allow(pkey); sys_pkey_free(pkey); + dprintf1("pkey_faults: %d\n", pkey_faults); dprintf1("orig_pkey_faults: %d\n", orig_pkey_faults);