Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6029807iog; Thu, 23 Jun 2022 09:54:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vCBSWB9S8aGNxM6vUd0PO6S4UTjJ2Z4QdeA5/A6Kr2h0chpF5tRnsfwjTxBPtY+EBNMLp7 X-Received: by 2002:a17:907:7fa9:b0:711:d214:36cd with SMTP id qk41-20020a1709077fa900b00711d21436cdmr9108381ejc.600.1656003249560; Thu, 23 Jun 2022 09:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656003249; cv=none; d=google.com; s=arc-20160816; b=zJQb7Mxx5D2/5/y5WgVh8yBQT+dddVLFg+4FKJqXu94QCYn3A7RSv5OiDaqzokwRVZ LepPyei3ysi2XCm14mP40Algni4p6JjiwY/4U1frEkQMfSZHYU7uafMAMFgiE7IxHm1R Ic8XMqnzP8XMj6hArcoXkRhdonxDH/l8NFEJ/la6syOgCrMKn6JyUAF3U2JmgqCn2yZH 8ud2HiORjcl/ouAKzylmSiM0Zz98rNHDioJU4yEwV1jPC+yHKrlFfzQZiSMVt3UIfgd4 jMnl9YEgu/Wjo/asbLBR53c2KfZ36UZIxaLk2nhOEe3h+6UKemVMST68syNKrT2IA3xB MRpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GFc3YPOGMu5rYYZIXbO9nWdByw2BjRmKYsH1e39VCJ4=; b=Pva5ohTZcobPNpJdgfc+dOmw+lx+fwRMA2GKZfVQ1Np2jV4GINEWIkGK7JvhrAcNMW pOOxig7IyZWu+C3gjKhUGG2n6TmdyavBvZqGEVC5PRM7PqS+TzZHhqUb/Q6lgNcHcOIS 0Ur4EpZn9FuYFnfT5h24sKZr606hHn1S6pv2yjSd44JIDTE43a+Gb4YDXeBTG6K0yp8m 3SuCAjEIkPESYNqbrKW07d4l0Xbs5/mxiBT6vcvLFEKUuLyNns4F7Mgg5t/JteU1qdsY gudR/APXISRaBSLNfZYfOBCncQ8W9SSzoY+ele9C6pegvqldrCsKUeHHo93Npr/oVMXY 5G6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="zf/qSaPR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt10-20020a170907728a00b0071d94f55dd0si22114904ejc.225.2022.06.23.09.53.44; Thu, 23 Jun 2022 09:54:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="zf/qSaPR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232724AbiFWQsR (ORCPT + 99 others); Thu, 23 Jun 2022 12:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232729AbiFWQrL (ORCPT ); Thu, 23 Jun 2022 12:47:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CAB449B4E; Thu, 23 Jun 2022 09:47:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2E6D9B8248A; Thu, 23 Jun 2022 16:47:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80AFAC3411B; Thu, 23 Jun 2022 16:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656002827; bh=FJaXs/WxS/PjUiKaRJNrn1pyHd6fKqWMW76i91Xqpic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zf/qSaPRpn1a9gqbLLb+el27+5mzp1IiC3g0E8Ha5FWjU80QFZT3QAo7TD7X2ptZZ JKN3zMx7nnkWiIY3SA3ltVfVGUv/eZoGR+uZvL82kZzJux0Ekd8QLbT7LdhhdhbPZM pC2UDFKpgtOOogRTkMFsKf5F2BeYfwLdAqjoe+aw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephan Mueller , Theodore Tso , "Jason A. Donenfeld" Subject: [PATCH 4.9 004/264] random: remove variable limit Date: Thu, 23 Jun 2022 18:39:57 +0200 Message-Id: <20220623164344.183470132@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Stephan M?ller" commit 43d8a72cd985ca5279a9eb84d61fcbb3ee3d3774 upstream. The variable limit was used to identify the nonblocking pool's unlimited random number generation. As the nonblocking pool is a thing of the past, remove the limit variable and any conditions around it (i.e. preserve the branches for limit == 1). Signed-off-by: Stephan Mueller Signed-off-by: Theodore Ts'o Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -478,7 +478,6 @@ struct entropy_store { int entropy_count; int entropy_total; unsigned int initialized:1; - unsigned int limit:1; unsigned int last_data_init:1; __u8 last_data[EXTRACT_SIZE]; }; @@ -496,7 +495,6 @@ static __u32 blocking_pool_data[OUTPUT_P static struct entropy_store input_pool = { .poolinfo = &poolinfo_table[0], .name = "input", - .limit = 1, .lock = __SPIN_LOCK_UNLOCKED(input_pool.lock), .pool = input_pool_data }; @@ -504,7 +502,6 @@ static struct entropy_store input_pool = static struct entropy_store blocking_pool = { .poolinfo = &poolinfo_table[1], .name = "blocking", - .limit = 1, .pull = &input_pool, .lock = __SPIN_LOCK_UNLOCKED(blocking_pool.lock), .pool = blocking_pool_data, @@ -1280,15 +1277,6 @@ static void xfer_secondary_pool(struct e r->entropy_count > r->poolinfo->poolfracbits) return; - if (r->limit == 0 && random_min_urandom_seed) { - unsigned long now = jiffies; - - if (time_before(now, - r->last_pulled + random_min_urandom_seed * HZ)) - return; - r->last_pulled = now; - } - _xfer_secondary_pool(r, nbytes); } @@ -1296,8 +1284,6 @@ static void _xfer_secondary_pool(struct { __u32 tmp[OUTPUT_POOL_WORDS]; - /* For /dev/random's pool, always leave two wakeups' worth */ - int rsvd_bytes = r->limit ? 0 : random_read_wakeup_bits / 4; int bytes = nbytes; /* pull at least as much as a wakeup */ @@ -1308,7 +1294,7 @@ static void _xfer_secondary_pool(struct trace_xfer_secondary_pool(r->name, bytes * 8, nbytes * 8, ENTROPY_BITS(r), ENTROPY_BITS(r->pull)); bytes = extract_entropy(r->pull, tmp, bytes, - random_read_wakeup_bits / 8, rsvd_bytes); + random_read_wakeup_bits / 8, 0); mix_pool_bytes(r, tmp, bytes); credit_entropy_bits(r, bytes*8); } @@ -1336,7 +1322,7 @@ static void push_to_pool(struct work_str static size_t account(struct entropy_store *r, size_t nbytes, int min, int reserved) { - int entropy_count, orig; + int entropy_count, orig, have_bytes; size_t ibytes, nfrac; BUG_ON(r->entropy_count > r->poolinfo->poolfracbits); @@ -1345,14 +1331,12 @@ static size_t account(struct entropy_sto retry: entropy_count = orig = ACCESS_ONCE(r->entropy_count); ibytes = nbytes; - /* If limited, never pull more than available */ - if (r->limit) { - int have_bytes = entropy_count >> (ENTROPY_SHIFT + 3); - - if ((have_bytes -= reserved) < 0) - have_bytes = 0; - ibytes = min_t(size_t, ibytes, have_bytes); - } + /* never pull more than available */ + have_bytes = entropy_count >> (ENTROPY_SHIFT + 3); + + if ((have_bytes -= reserved) < 0) + have_bytes = 0; + ibytes = min_t(size_t, ibytes, have_bytes); if (ibytes < min) ibytes = 0;