From patchwork Mon Jun 18 08:14:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 10470139 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 9F4E36032A for ; Mon, 18 Jun 2018 08:38:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 907CD2842E for ; Mon, 18 Jun 2018 08:38:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84CA628863; Mon, 18 Jun 2018 08:38:20 +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.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE 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 3A85A2842E for ; Mon, 18 Jun 2018 08:38:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFB4D6B0272; Mon, 18 Jun 2018 04:38:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BD27C6B0273; Mon, 18 Jun 2018 04:38:17 -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 AC2376B0274; Mon, 18 Jun 2018 04:38:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id 69ABC6B0272 for ; Mon, 18 Jun 2018 04:38:17 -0400 (EDT) Received: by mail-pg0-f72.google.com with SMTP id e11-v6so4972378pgt.19 for ; Mon, 18 Jun 2018 01:38:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:user-agent :mime-version; bh=o3ug7d40MuezWflKKn0twKw7kWO0jmkwk8cwTwIwubE=; b=MDHQcB1VMVLZYO59XCfFF/F9z/ib/sw4gI7jL4ISfua5E3QOibz5NEZWXXzEvasp0C 2t3/+/wPD1/ni1SJ/qUGKGdM8/JkccLe+eRJj8JNKfefUZC1mwLFjyBsm1qrR9rCfbAz e5g7e+Mh4Wc3TW313Ow3GiquLLQa+KB+PevgBfqulN3+WmfysmA483q22mNhO981ncYe uT+ccYmvvxN0lQNvFwdVoaJFTINv8HTl0FCRwdHEhDw1XZIX7KqZHE7SggL9BVBFOfV7 KIx0by4YJ9OMCxrrboO8y94kAfGNuPSAhv/f81WkcZciVBpUXmMYDVTrt/UlvMlOtudv wUFg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org X-Gm-Message-State: APt69E05NDlmf23y8fH0JowIeKQPqzthpaWyXSV1J6vX/S4QH2f4tu5V K4RatlncFGnhIWWvahNvqtAFNKrQfb1wZUTvRFCafezgY+u97x7vtJ1ExFAJoMY5V0POhQMe1kM ivsgigIgtdYfNXdpKNj58hQXapEwyGK8WP44SzmWt2ZQCHfS8/yzOms5BsHOwuKz62g== X-Received: by 2002:a62:993:: with SMTP id 19-v6mr1159928pfj.105.1529311097074; Mon, 18 Jun 2018 01:38:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKeXAXjLaP9KDsRuj/rSsyX555BjG16ckyo5DX1T4nwiW0J9nnsmW156NHZo4a1/bgHGnY/ X-Received: by 2002:a62:993:: with SMTP id 19-v6mr1159877pfj.105.1529311096136; Mon, 18 Jun 2018 01:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529311096; cv=none; d=google.com; s=arc-20160816; b=EP5doUG90mLFxVkxC0l/1WMWOVkROqqPQpdZq/oV4/3yIwNkjgaUwXoRedxT2M+9O5 D6o79yF/6JLJBl7AiZFL1J0QxFXN/xZ86OqfpP2vwkl9Rsy3d9F2bhYp7ZCLU9KLl+o3 N9u6WPltVRNVYTmUtKji3tcaw/XND+iVcW/7izBfbyaSLq+TEcO/TSJHzIqBUy2KTeH7 hUADt4KLXP3dXcASURRXlMTWgJX15TpuArEoDNhyAdUtiubUfEgfMDUxJUk+ZF3iY4dq yBoqhFrb8t3f30rK8aG4n30rwTMtCYkJcuw2KA9rzjuJxcFV+8eVgCcujPFshw6JJ3q1 tC5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=o3ug7d40MuezWflKKn0twKw7kWO0jmkwk8cwTwIwubE=; b=Y2HcOrm9ce6n6gZsk3/RsC7YGn1co+IR0q/uY923DlBQ5T7IyFr1h6j0t8M/4g1DLS mpSy91fdbBsHzBNFAi2RR8KfoBWMA4kmnGnxi5BcV9ObM8Bo191izo6ix2J9tXZpi8+N iATLxYJnmUHSsNBc0wHtPYzRU+fh/HnPGjW1ctgOlTx0/6DSmZyBrcExVsdYlfTa0uqQ h9HNpdd434tX3oQLZdeFOI/aoXCrmmx5+d3JZ0LUG/LYH4AokpWxMhc4ntaeKq8nUemS szwEhpKH8jouNl3pF7Z/RokOjsDJlYmnpyV0o7Uw/lsv0ZTDoSRmdoTEWcK4vn/02a+E 4emg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org. [140.211.169.12]) by mx.google.com with ESMTPS id x33-v6si14376784plb.512.2018.06.18.01.38.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 01:38:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) client-ip=140.211.169.12; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3C200CBA; Mon, 18 Jun 2018 08:38:15 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Hansen , Andrew Morton , Dave Hansen , Linus Torvalds , Michael Ellermen , Peter Zijlstra , Ram Pai , Shuah Khan , Thomas Gleixner , linux-mm@kvack.org, Ingo Molnar , Sasha Levin Subject: [PATCH 4.14 161/189] x86/pkeys/selftests: Fix pkey exhaustion test off-by-one Date: Mon, 18 Jun 2018 10:14:17 +0200 Message-Id: <20180618081215.696074572@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618081209.254234434@linuxfoundation.org> References: <20180618081209.254234434@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dave Hansen [ Upstream commit f50b4878329ab61d8e05796f655adeb6f5fb57c6 ] In our "exhaust all pkeys" test, we make sure that there is the expected number available. Turns out that the test did not cover the execute-only key, but discussed it anyway. It did *not* discuss the test-allocated key. Now that we have a test for the mprotect(PROT_EXEC) case, this off-by-one issue showed itself. Correct the off-by- one and add the explanation for the case we missed. Signed-off-by: Dave Hansen Cc: Andrew Morton Cc: Dave Hansen Cc: Linus Torvalds Cc: Michael Ellermen Cc: Peter Zijlstra Cc: Ram Pai Cc: Shuah Khan Cc: Thomas Gleixner Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20180509171350.E1656B95@viggo.jf.intel.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/x86/protection_keys.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c @@ -1163,12 +1163,15 @@ void test_pkey_alloc_exhaust(int *ptr, u pkey_assert(i < NR_PKEYS*2); /* - * There are 16 pkeys supported in hardware. One is taken - * up for the default (0) and another can be taken up by - * an execute-only mapping. Ensure that we can allocate - * at least 14 (16-2). + * There are 16 pkeys supported in hardware. Three are + * allocated by the time we get here: + * 1. The default key (0) + * 2. One possibly consumed by an execute-only mapping. + * 3. One allocated by the test code and passed in via + * 'pkey' to this function. + * Ensure that we can allocate at least another 13 (16-3). */ - pkey_assert(i >= NR_PKEYS-2); + pkey_assert(i >= NR_PKEYS-3); for (i = 0; i < nr_allocated_pkeys; i++) { err = sys_pkey_free(allocated_pkeys[i]);