Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6138572iog; Thu, 23 Jun 2022 12:09:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sFhEOPxHRZJvP6shGVWA66bwtwyBna2+8da7FEgGK4ztIknSo8TwG7KCVL+FdhMt3/HkKa X-Received: by 2002:a17:902:8bc1:b0:16a:187c:8719 with SMTP id r1-20020a1709028bc100b0016a187c8719mr26028416plo.43.1656011341487; Thu, 23 Jun 2022 12:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011341; cv=none; d=google.com; s=arc-20160816; b=gyaSD+WPCAKvaEm/6/zvNwh3JVHcTPXGCFbSy7wHCIbSdg25F5FKfm+t+e4YkT/1t8 FA/T8MO76wFBU3kQPPanpaZR3Py7cW/Rnn0GBJuIb5eFE2r3lCrDJ7Q3Q0lHZcvYWwh3 0xIQDa9U/DWhFvlSlxBtTtFnyXHkce2luZQEZVfTuXpN4ziBHYqmzVmShy9Kwn+GHE8p f5zXysNAnOVk7glfm+FA/cDMIyTFI1t8ds013+DxdZb2NmW8AFviEDRcD6v5SxdJ+33U 5A1VBweOwK+Jf58lYlKWlYQuv9vf/1DKXYSdjqprq4O09e2e5nbkvU5JIUnwfFpmKHDr kQng== 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=bVdS6rcos+RgEEjl1WB4zk+hWY6Kg4MQfLZ3uDdLN3c=; b=1IvIYoH3HolsFZu6osKbCJUWa8Sg8QeYJErEVS4kuLb+t1fZHVstgWuPKLFK+Oy1t2 lYVayGLUJnsilyQsU9FuPVHkPPfauwu3NeVET0vs/3Tjww1qSLikfN959wKm1UbzuLpd QL/11VrX80f/nTqeW0qP96LgJvrRY82hrNaFN5Rd7aHb+Jl3bRgT8eumCknGTLVrDoEz mhwbU+j9dGZX3PqXe2nHLVU4Y9+XocXEmWrOioX9FMtYfiiRy0e7pEMx+LjvL7c9gujS FcA/vUgFfkzPWLhiUvW3rUa6ZxmEXoiQnfCYVbanfwMVsWXoiLvMJKYCSZfDDQQ7cJ/3 1OYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=of3spjlC; 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 n18-20020a170903111200b0016a61da090fsi475928plh.86.2022.06.23.12.08.49; Thu, 23 Jun 2022 12:09:01 -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=of3spjlC; 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 S235458AbiFWSAE (ORCPT + 99 others); Thu, 23 Jun 2022 14:00:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235986AbiFWR6S (ORCPT ); Thu, 23 Jun 2022 13:58:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F5F2B01F2; Thu, 23 Jun 2022 10:16:00 -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 dfw.source.kernel.org (Postfix) with ESMTPS id E2F0C61E07; Thu, 23 Jun 2022 17:15:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C57D9C3411B; Thu, 23 Jun 2022 17:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004559; bh=cU4v9cxY2ZRL2hjxOHLz3BTe1f4WKimpk7DcIKzUNLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=of3spjlCjLJ/Ip6pqmQBwBKZxU+JLfpf2Ia116ZH1aLsBXFAhp0r4Of5cOU+yzTJm bCTW+ukqrccRitQqxIrzgFHGWFVWQF7OvhBDmoB7Gvw1ZaQDqIdxLcR/CzLwc6vH6X p3BeZXKsdB2E+HhppB6oLzkTD4Gp3BWkm9NdV3qM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dominik Brodowski , "Jason A. Donenfeld" Subject: [PATCH 4.19 074/234] random: only call crng_finalize_init() for primary_crng Date: Thu, 23 Jun 2022 18:42:21 +0200 Message-Id: <20220623164345.154389102@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@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: Dominik Brodowski commit 9d5505f1eebeca778074a0260ed077fd85f8792c upstream. crng_finalize_init() returns instantly if it is called for another pool than primary_crng. The test whether crng_finalize_init() is still required can be moved to the relevant caller in crng_reseed(), and crng_need_final_init can be reset to false if crng_finalize_init() is called with workqueues ready. Then, no previous callsite will call crng_finalize_init() unless it is needed, and we can get rid of the superfluous function parameter. Signed-off-by: Dominik Brodowski Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -800,10 +800,8 @@ static void __init crng_initialize_prima primary_crng.init_time = jiffies - CRNG_RESEED_INTERVAL - 1; } -static void crng_finalize_init(struct crng_state *crng) +static void crng_finalize_init(void) { - if (crng != &primary_crng || crng_init >= 2) - return; if (!system_wq) { /* We can't call numa_crng_init until we have workqueues, * so mark this for processing later. */ @@ -814,6 +812,7 @@ static void crng_finalize_init(struct cr invalidate_batched_entropy(); numa_crng_init(); crng_init = 2; + crng_need_final_init = false; process_random_ready_list(); wake_up_interruptible(&crng_init_wait); kill_fasync(&fasync, SIGIO, POLL_IN); @@ -980,7 +979,8 @@ static void crng_reseed(struct crng_stat memzero_explicit(&buf, sizeof(buf)); WRITE_ONCE(crng->init_time, jiffies); spin_unlock_irqrestore(&crng->lock, flags); - crng_finalize_init(crng); + if (crng == &primary_crng && crng_init < 2) + crng_finalize_init(); } static void _extract_crng(struct crng_state *crng, u8 out[CHACHA20_BLOCK_SIZE]) @@ -1697,7 +1697,7 @@ int __init rand_initialize(void) { init_std_data(); if (crng_need_final_init) - crng_finalize_init(&primary_crng); + crng_finalize_init(); crng_initialize_primary(); crng_global_init_time = jiffies; if (ratelimit_disable) {