Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2931907iog; Mon, 20 Jun 2022 07:45:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tg9Peg3aXV/Cb2ggdNm7MMJK8zuNyhDsMxP5zDX7uJqiULAHKCoNxB10vReqnn+RnN15lM X-Received: by 2002:a17:903:2347:b0:16a:33cd:5308 with SMTP id c7-20020a170903234700b0016a33cd5308mr321902plh.122.1655736309596; Mon, 20 Jun 2022 07:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736309; cv=none; d=google.com; s=arc-20160816; b=GpfdNWSN08q+VofRTPdQxpq0CFSiRsxLI9uGFn5yUS0h4zfLmYXAZ4LmZR3XtScAg7 zA9lyAiLFzcUtAjmf9x4JZuTYwSevH/tBXW/uMwky/hydfv+4xmI4bNQ8MtlBFKv2VBH NI+sMsYTbTYwHBB0HmAlSZgbPIEHNJLOCR2mY2FCrBsmpS9NozPi3dn6Iq0epN/c5rhn XbFUxvDwtqTPX+Wqtsjw9T+6qYcKR+Tzr6hUhYyPcf1OMJcGs6l2el9nultkpTgRN4Da woffKBQmVMLhknXPH/mOhfho2KbOq7UHLuyA27cthmrsoPXCQz/8vSJuQzVxdruDeMUW ZHTA== 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=ku1Ju5wAw0WDX4qHBbwIsbDaFUmht2Mojp53fcCOWFtcKpFdqVSEfSTxBB+DDnwgor CVENH3YdDYXbAG1bW89RF00GdVR0X4hs+eCjgCfO6HPZMR0GK5OCw3jm0ntXjHBsN7z1 YQC0qBohWchNiatneWiPAh/3WYp0ZRKHs8L7Le2v11KIN5yo6WXQRVdbGA2jQxRqkmfo 5dr7yGhB4mTqybJOMfGuKsq7U73VhfQiil140Iv1L9m6XU341NckAQXaBcN+vOUveViO Ay/PkzBTIzvQ+7UWYgSKY3Ofo4P7zg4R87MaNLqnroFDIguy3oVaNnG/XnojZWgAanI1 1QAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hUe5lJfI; 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 z2-20020aa78882000000b0050d1e1735aasi17719071pfe.191.2022.06.20.07.44.57; Mon, 20 Jun 2022 07:45: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=hUe5lJfI; 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 S1347827AbiFTNpH (ORCPT + 99 others); Mon, 20 Jun 2022 09:45:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347564AbiFTNnH (ORCPT ); Mon, 20 Jun 2022 09:43:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F9C72B1AD; Mon, 20 Jun 2022 06:15:38 -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 E2D96B811DA; Mon, 20 Jun 2022 13:15:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 402FEC3411B; Mon, 20 Jun 2022 13:15:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655730936; bh=/S1iYXeszMNaRYv4XNqtEEGXovrfJyB6SAipvJMmfqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hUe5lJfIvoUltFhmXxnN+TK7zJlbgIZpavKFPhSLAaqkqrdHPhJuOoEIiEAftWNiK Po8ZlP6cWNaOpIntNxhQhqz3+dgzCm/eNfMmxjl7JqQ2O5cLX0YS7Z8fKwajUAY7X/ YEssm324SpOl5KA8EfANgQ74ufiYgJj86O+4qW1M= 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 5.4 101/240] random: do not take pool spinlock at boot Date: Mon, 20 Jun 2022 14:50:02 +0200 Message-Id: <20220620124741.944724890@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124737.799371052@linuxfoundation.org> References: <20220620124737.799371052@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;