Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2432552ioo; Sat, 28 May 2022 13:29:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVu+vJGt0t6xdkfxdS2YOWZ8XDdszo9QP/fExobetMX+s00+OaR+9tDxDEC2MCEtNq8Dx2 X-Received: by 2002:a63:2319:0:b0:3fb:fe88:5831 with SMTP id j25-20020a632319000000b003fbfe885831mr136020pgj.85.1653769799721; Sat, 28 May 2022 13:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653769799; cv=none; d=google.com; s=arc-20160816; b=yHQjbfl9wzCKaMhNw4UJyOUMrbhCNYYlKndRwM+LWkb1VvQJ5+BBjmiEN906/yfngu LXudb6k3vTulTeS0DRfSeLB3OzGAGfgR7IXiusIE6Yw+oQz06B+mX2ShUGh1rxZQ5RuJ DUamBuGLdryrK3FufWZ42Ac/VnqzhSsmeQ1HLQ7Ee8BGY7F1SzjY7OP8o4u6TlsowxWf nFL8nWa4uuk69IAKbEr3kvzZk/Ut1U4AWo4dybjtp6ir5FzQ3xpi2b/RqccjmGKV2KGc V9JmpYn6FH7i5YD7gVSXNn/HdaZzBmurISnGF+1oN4k/Cvzg5nqzOMB/DQ4Npghufs/U pnnQ== 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=mPu6XEZjN2/wR5GKnNez9TVqF3eidjtWChG8Dj/FHM0=; b=K0qGLU1YGjC0oO3JtMem9jpb8tfzaeE1t8FBwMS8PAAmiVABMeSaUE8AUfgoRw5OZF ZSeMUTcuKNXx8nYGaLBhgbre6m8gUUOLBvGnTFEk6/dKEAdSqd0b4NiPP2NUbpLWs1DW IDFp8ybwjwfTa7RbHi7apQzYnYpr5emkCh7KMaoW58oYfuRdqqZKIbNplQXPXYj7qPok CnuYbc/6P4Nf6jC8UHbxKJ2HCrnd6Thfxo/aSR8AlgwQAedCw1hS34DDxrfD9dnFCcz6 kgE6R4u08sFbMIZSfLE+5WEwe/MmaP/fExls161CB32XWLQ3/pvUhDLn4CRC7qo77+Ka C/nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fw8BhT0q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g2-20020a63fa42000000b003db2e6e3c5dsi10316281pgk.707.2022.05.28.13.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:29:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fw8BhT0q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 803071146AA; Sat, 28 May 2022 12:39:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235841AbiE0Lom (ORCPT + 99 others); Fri, 27 May 2022 07:44:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351698AbiE0Ln7 (ORCPT ); Fri, 27 May 2022 07:43:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2729F131F1A; Fri, 27 May 2022 04:40:53 -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 967B7B82466; Fri, 27 May 2022 11:40:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07FCFC385A9; Fri, 27 May 2022 11:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653651651; bh=IrtVp04WXrGF+u/Jx0GCro9bCp6PLkr34Fu9nMRutX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fw8BhT0q3/ZwVMUrKEB/8zYJnN0o32gx35pO5mTUkJn2VHphXUH40AgAHNCuAbQH6 eu2PgISA4xeuTLHaCXwHrSy74BxeJfTpIb/Kd5uaOXUAUPGvkQfyRynsafIdDakBw1 vDCB5xuaLgjc0kO53Ptbefkqju5DN6P2fPScY+iI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Morton , Stafford Horne , "Jason A. Donenfeld" Subject: [PATCH 5.17 068/111] init: call time_init() before rand_initialize() Date: Fri, 27 May 2022 10:49:40 +0200 Message-Id: <20220527084829.166442186@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220527084819.133490171@linuxfoundation.org> References: <20220527084819.133490171@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=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 fe222a6ca2d53c38433cba5d3be62a39099e708e upstream. Currently time_init() is called after rand_initialize(), but rand_initialize() makes use of the timer on various platforms, and sometimes this timer needs to be initialized by time_init() first. In order for random_get_entropy() to not return zero during early boot when it's potentially used as an entropy source, reverse the order of these two calls. The block doing random initialization was right before time_init() before, so changing the order shouldn't have any complicated effects. Cc: Andrew Morton Reviewed-by: Stafford Horne Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- init/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/init/main.c +++ b/init/main.c @@ -1035,11 +1035,13 @@ asmlinkage __visible void __init __no_sa softirq_init(); timekeeping_init(); kfence_init(); + time_init(); /* * For best initial stack canary entropy, prepare it after: * - setup_arch() for any UEFI RNG entropy and boot cmdline access * - timekeeping_init() for ktime entropy used in rand_initialize() + * - time_init() for making random_get_entropy() work on some platforms * - rand_initialize() to get any arch-specific entropy like RDRAND * - add_latent_entropy() to get any latent entropy * - adding command line entropy @@ -1049,7 +1051,6 @@ asmlinkage __visible void __init __no_sa add_device_randomness(command_line, strlen(command_line)); boot_init_stack_canary(); - time_init(); perf_event_init(); profile_init(); call_function_init();