From patchwork Mon Jun 18 08:13:49 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: 10469867 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 EFADF6029B for ; Mon, 18 Jun 2018 08:28:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFB6028861 for ; Mon, 18 Jun 2018 08:28:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4878288B8; Mon, 18 Jun 2018 08:28:04 +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 5E80728861 for ; Mon, 18 Jun 2018 08:28:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C7A6D6B000E; Mon, 18 Jun 2018 04:28:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C0BC26B0010; Mon, 18 Jun 2018 04:28:02 -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 AA71F6B0266; Mon, 18 Jun 2018 04:28:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id 60F196B000E for ; Mon, 18 Jun 2018 04:28:02 -0400 (EDT) Received: by mail-pg0-f70.google.com with SMTP id b7-v6so4962394pgv.5 for ; Mon, 18 Jun 2018 01:28:02 -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=4Edk8mcCkNpmAExd307VxplCjNaamcu3DXDNaoMhr5I=; b=D1kYxoLLAj73TLuBSFplCEEGnYO/lwH+zJ8E1r+yobEJtQaQA2torMht2rSqxJhJq5 xUvpkwP54Dvm1NLk7neqbuLTXEnjAsb/3mnZZjpNRd1o9Lo4Z8xYt5/AEMXVznWj0IlV CbR+jzos1LcLpBSrC+KaPN5NmTX/Ye/Aj+Rkq0YD0AjT/SvSyCv270BeXTVhT9B9QndE g1h+tTvgzthjkUwTibuaF7zutLeI8/S9pLKGXQi31/u3hv7aLVUj+QvDNv0mSut39MKm 1WnC7NCgEB4HzQWpQ45wMdm6qGGi0Ru1KzDrPVF/IVr6amz8vXEccRsVe0VlECBkYsBt feTg== 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: APt69E0kSwIpbDgAL9Qp/IdCFKj0nVMKaB0sdWFnJWkWj19AxJcU78c1 wAbxnWr6f45GHgtTcqX6MWB9JzUSmiomhodTlkXMGFBfFMd38tAUeFQHuU0BvQtS7iSHiubDmnS hrMUAFV1TiFalYi9AnlLAKBmlKC3Xfm+q8jyn59dZcgg3PMR36cYi4W8TfFY08lpmvg== X-Received: by 2002:a62:5991:: with SMTP id k17-v6mr12476834pfj.94.1529310482075; Mon, 18 Jun 2018 01:28:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIzg85CgcJJSldsaOXeqzzjbhr570I1xifHwVjVKf0ja/ESFcaksQwf6VSCnzZDhw33KmUG X-Received: by 2002:a62:5991:: with SMTP id k17-v6mr12476774pfj.94.1529310481184; Mon, 18 Jun 2018 01:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529310481; cv=none; d=google.com; s=arc-20160816; b=cF1qY1UnH0WwlpBkq+e48tL9qLV4ucrc4W2Z74k1jXqzLtMuXMyZaWHMnCP3T1hQYv /4PYF6bNxiQRpLvCSVh1EJIZ0Wm6PVLQgUpYu4p0NI7PUbFWQhtJ6nZx1SEQZiPVRZoG rGThtdfqMxnKF0aQzTOYdT8FjriAP4QtjwOjgF/cNSdgLituPi3DODXEq3zSlRSLLBZo Eg11vRkPaRiHwc0ddrv+xJcoqX/kMWIGMPf9Y/4c+M9/KGig3d0hQ7IYmqp6iRaPjrCE 6ji0aZalYYtQYAU2eXkkiprzrpbfXmawY1ol+CPuxjvOaqBXaSkFK6PeTUyZcWi+4rgc FRkQ== 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=4Edk8mcCkNpmAExd307VxplCjNaamcu3DXDNaoMhr5I=; b=w7Zxb/bteKWE60xsoE4e5xDI/QuePN+nyOksoJG3bz1ywwUxE/P2hrOczXwp5omd0o kjXk0iVztKyPBxN06uzg0KwcpeNX3huO5rIMOx/mGuntEEBJl9eKO0hdYkHJspWSoQqY ss4K+Vesig5GbeQuhgSoGkufEzb6GurggO9XsVe1VLOCBa8bT+OBTLx4sluZAnnwlkVS CQGf4H+zuLA0/YHCH0t2nGf4K3nERH/s2Yu7X2+c4oMosILD4Ms/OHQPtnGbBgVeAwXz V8c57DL39F0Z2l1foM/gYW/EQPSO2lcPDEX8mi18wXzq/GxdVgOq8K0wRyb88vp8mLIr lTmQ== 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 r59-v6si14062788plb.314.2018.06.18.01.28.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 01:28:01 -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 667E3C7A; Mon, 18 Jun 2018 08:28:00 +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.16 244/279] x86/pkeys/selftests: Fix pkey exhaustion test off-by-one Date: Mon, 18 Jun 2018 10:13:49 +0200 Message-Id: <20180618080618.870305371@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618080608.851973560@linuxfoundation.org> References: <20180618080608.851973560@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.16-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]);