Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp8861ybt; Tue, 23 Jun 2020 13:53:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQmqLbbsAK3nc0DYrLxTxeee17lGOMe6BcoqrQosiOgZtEF42tDdL3UtrdA4DcXVCcbI35 X-Received: by 2002:a50:afe1:: with SMTP id h88mr19154236edd.295.1592945614579; Tue, 23 Jun 2020 13:53:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592945614; cv=none; d=google.com; s=arc-20160816; b=vK1/r1YAd84lAkqMyzdQTDh9OeyoHb/ShJqDU40iGBJ2Kb3QquWnwvd4vDloYq+r6O GVC2Yix0N4xlO0MKRTFWTcpKoelmnAZGWdu7P48540zwdcFhya95dLphNQCesRg17PV9 6ZuJjcPtv0O/KRuneueJg90sp2M242OlOciOp5rjW5L+JdUsOlV6XD9iTqgXm8SJ+y8s canf5KrZvGqWbEcWEWSfVGcrFTzlM01edrzI1F1JfivRFFclUzuL9e9/ukXDee6bHuHY Ur7enHJo2Dfnk3wKP8lZx1stK03zWStckn69l/IlIhOcupAzpV4IU0A0Urzlku1jkFRr +7Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=quACXbWnLs52dk9zEg2055W+Q2fJxBdJ6UgOHjZ7nTY=; b=d52jCvN2wKeqp7ou5Ih/BKOyUz/nYgJBiOJhBl14hx86wuYadQhHVWUE+X4ek6tcH5 ufIBi/gdN3r+wQZHNmqxY/M1NKbAFDGMD7SBOO9o25mz+74aKJRG7pnaSmSA81G4SAW4 Mf9r2WXlon5bJYpRKAYKbWrMZXHMVMfjNM6kmXlBCVcfWgcKE+n5e83SQVHZQwwJTSeG nqJpjfLfWE+IdZ2bEfGXLXsBbs3N+Uqd43tJTKg3nCAv6FsfTYE7qwR1KtNXYv3Zz/7O 49eJxJGrERYRSCvEqVDasf7y4GbRir1V6fUBbLKYRKy/fu2SOxQCvmMn13Gsk7h6gip3 G4Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="OB6/cIi9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ck9si11558134ejb.371.2020.06.23.13.53.11; Tue, 23 Jun 2020 13:53:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="OB6/cIi9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404067AbgFWUrn (ORCPT + 99 others); Tue, 23 Jun 2020 16:47:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:45922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404045AbgFWUr3 (ORCPT ); Tue, 23 Jun 2020 16:47:29 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA8F820781; Tue, 23 Jun 2020 20:47:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945250; bh=WUZmUys8GXwbBRoi2bD5fzkBN59mbeajwnIIzjFuBIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OB6/cIi9xo8kbrqYOLLwMZ6J2G0MTqvdn1qzIymgTwaGpDjGEBguxK2s5Qz4CbZAq /fmdvZosvrN3z/6mXI9CjyXeBywlJR+HArETSLEQF1ekXp+36g3T+3u15tBYJCoceo dV60/q5L/z+nqYpfw9DbH8dYSpy7bWnAhfDN/pnk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ram Pai , Sandipan Das , Andrew Morton , Dave Hansen , Florian Weimer , "Desnes A. Nunes do Rosario" , Ingo Molnar , Thiago Jung Bauermann , "Aneesh Kumar K.V" , Michael Ellerman , Michal Hocko , Michal Suchanek , Shuah Khan , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 096/136] selftests/vm/pkeys: fix alloc_random_pkey() to make it really random Date: Tue, 23 Jun 2020 21:59:12 +0200 Message-Id: <20200623195308.498764523@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195303.601828702@linuxfoundation.org> References: <20200623195303.601828702@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ram Pai [ Upstream commit 6e373263ce07eeaa6410843179535fbdf561fc31 ] alloc_random_pkey() was allocating the same pkey every time. Not all pkeys were geting tested. This fixes it. Signed-off-by: Ram Pai Signed-off-by: Sandipan Das Signed-off-by: Andrew Morton Acked-by: Dave Hansen Cc: Dave Hansen Cc: Florian Weimer Cc: "Desnes A. Nunes do Rosario" Cc: Ingo Molnar Cc: Thiago Jung Bauermann Cc: "Aneesh Kumar K.V" Cc: Michael Ellerman Cc: Michal Hocko Cc: Michal Suchanek Cc: Shuah Khan Link: http://lkml.kernel.org/r/0162f55816d4e783a0d6e49e554d0ab9a3c9a23b.1585646528.git.sandipan@linux.ibm.com Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- tools/testing/selftests/x86/protection_keys.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c index 5d546dcdbc805..b8778960da106 100644 --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c @@ -24,6 +24,7 @@ #define _GNU_SOURCE #include #include +#include #include #include #include @@ -612,10 +613,10 @@ int alloc_random_pkey(void) int nr_alloced = 0; int random_index; memset(alloced_pkeys, 0, sizeof(alloced_pkeys)); + srand((unsigned int)time(NULL)); /* allocate every possible key and make a note of which ones we got */ max_nr_pkey_allocs = NR_PKEYS; - max_nr_pkey_allocs = 1; for (i = 0; i < max_nr_pkey_allocs; i++) { int new_pkey = alloc_pkey(); if (new_pkey < 0) -- 2.25.1