Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6136766iog; Thu, 23 Jun 2022 12:06:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vsNWOdytqchWhDv1+L7R91hWVrle049azcwa2TI0pvaSD9nWOMImH0n/aLl/8FxuyONcB2 X-Received: by 2002:a17:902:d48c:b0:16a:629e:2f21 with SMTP id c12-20020a170902d48c00b0016a629e2f21mr1983245plg.148.1656011217777; Thu, 23 Jun 2022 12:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011217; cv=none; d=google.com; s=arc-20160816; b=xyZ9/LsHpNyN8ABofPcZ94Ztu0lhYXpftBiYcYGsYC4d/xMRsY+UIbCRyqFLuN+Wgp bGGR4JJn4xyugvr10yR8plQThicEBj5RBIvRhvmdm4mcGbVF3W8EyuHuKaVgDcvUgLu1 VG+YrCw2nQq2G/yWtnRHLI++SNnbMo1n8GSbF4C/VYdksUxkOJM1elrtBVCZUjiGqFxX 8Sb9fTIWq3O/oys5s9reE24JjflI1ffV4fY0ZYOnob23NNobj2oydKXNIkrH0+BXRdfQ odG38YuoReH8cwmizbh3arT74YlYIU34WrLlH+Mz2JCSiTOX+iV239a6ocTRT26wrKlt 5QFA== 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=DstGA8lC+CEC8LRcEX3lBRvFWbdpTjArHYDO+RcmSKc=; b=s3HfQcA0rQata417+BQUVs+35eu4hTnEHi0YzOIfbTTEoUB6pCai3P7G5VXaerT/Yi JhRDVK+EN5UDPNz73FQAXkOrdTXr12TFYcHDoccYNKb/RLmHmup1mIMqQTjh2UMSViX1 gP+gq/8YU3lLB2T+7tqjBSQAYQSPF9kxmwoWa8Ibk58xqFOKApDCQUcsoxbD5MK5vsUk mZeiNtEK+NnqmRKtdKT8j+lLg5ubmEupbyUaH9A6Tf/e+nJ+YsQHApEdllV2PNWNhiHv khPccoo4RgUL/ZcPHc5t6h/0/6FpYhlAfXAFDhfhQbG4jOGxEfEgBIjJwtDZlw9o+wnh D8Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ty034qwv; 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 bf20-20020a656d14000000b0040cbcf5f99asi17310472pgb.143.2022.06.23.12.06.44; Thu, 23 Jun 2022 12:06:57 -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=ty034qwv; 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 S235947AbiFWSF5 (ORCPT + 99 others); Thu, 23 Jun 2022 14:05:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235925AbiFWSF3 (ORCPT ); Thu, 23 Jun 2022 14:05:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2530DB8F97; Thu, 23 Jun 2022 10:17:32 -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 99A2D61DC6; Thu, 23 Jun 2022 17:17:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DC55C3411B; Thu, 23 Jun 2022 17:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004650; bh=/S1iYXeszMNaRYv4XNqtEEGXovrfJyB6SAipvJMmfqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ty034qwvGH22HkWmz0fg9ouYbCOsKAS5031mUXheyL8uEJ4Tbos79+zlJdgS9PsVH bvRSq3bhMqoJpfYH5p5WfJOf8L7nvBiarPsKpKVPZFzCpYt59+9H2WH7wrdjBsygVM VvpD91YeChEfpQsmSYyBD8OGzjlXA2eAWL/wEdpo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Dominik Brodowski , "Jason A. Donenfeld" Subject: [PATCH 4.19 106/234] random: do not take pool spinlock at boot Date: Thu, 23 Jun 2022 18:42:53 +0200 Message-Id: <20220623164346.057560831@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: "Jason A. Donenfeld" commit afba0b80b977b2a8f16234f2acd982f82710ba33 upstream. Since rand_initialize() is run while interrupts are still off and nothing else is running, we don't need to repeatedly take and release the pool spinlock, especially in the RDSEED loop. Reviewed-by: Eric Biggers Reviewed-by: Dominik Brodowski Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -973,10 +973,10 @@ int __init rand_initialize(void) rv = random_get_entropy(); arch_init = false; } - mix_pool_bytes(&rv, sizeof(rv)); + _mix_pool_bytes(&rv, sizeof(rv)); } - mix_pool_bytes(&now, sizeof(now)); - mix_pool_bytes(utsname(), sizeof(*(utsname()))); + _mix_pool_bytes(&now, sizeof(now)); + _mix_pool_bytes(utsname(), sizeof(*(utsname()))); extract_entropy(base_crng.key, sizeof(base_crng.key)); ++base_crng.generation;