Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6134679iog; Thu, 23 Jun 2022 12:04:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vysrg8AnglCrpnEJ+r9DUsjL70B65BR5FScb13KttQaFOCn02yM/wNMCZrRyBNwEyhH09l X-Received: by 2002:a17:903:2452:b0:16a:3b58:48fd with SMTP id l18-20020a170903245200b0016a3b5848fdmr13633920pls.67.1656011077765; Thu, 23 Jun 2022 12:04:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011077; cv=none; d=google.com; s=arc-20160816; b=LBVYiQtjiWxQ0HSjTtSpq1dA2xzweYAnRDAfl2QBMJqim3c8m2JqEuXzlciJT5DGdl 6MXcZ2IvDMvkTlfUUi+3WMn3ioDh96aFiQqYVkAXcW5DSF9gh6Qhs4seULtwSP8u1Q4u Dq/dkY3bFH7j4Jwc0zIWGqBI9uYoBAzVWBsKckNnOgjlrdv7znl0MiXLghZfiNBms9q6 9RI3src9iN47mH5Dc89BOLK5ToTaZRAGqYYEwIk17Ztk0es2KvCffV3yFkYTumjERJwq YAOmZKKekAEcyFsbOkXCcMReBRlWhaQVX/kQ3q4sOkK7O7zmyPOWCg5ooQtT5OUQuiMr 728Q== 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=R6HW+Qw6R+i/urlLy9Ufw9XDsh4JlxNEpef8mDsjX/w=; b=UpmjMGhqpNwPE0YobdLkiwwbAW2z/ofTfwRmndP6yaPJWq7GPS9tMej+b8MwNJj53I lGeCRrFslrt73s7lXOaE0/pwPTc8DfTEVwGgG/WBYzF6EC57Qnk4uKyIeCdOQaCmXZ28 MS6zoBgXfmAF0iOi6E+0aDcjsXMie3iG4KIvdhv91Vtd2pCUe/lhfFA3Ssh6G+fLSGuu mXFFWnVXC5k19BpHtsOGZFl6DNGfL4FcwC1wOYukEMCHzQq5LG81TlCPWK8ekUuK6Dl4 zX8hPXjMypIuRvkT8K7kP6ZZQe/FwVkMCaUa33QLgD6RojWYRI1+xPMFCN+atdQ4KhIM UL5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UD89Tzfa; 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 g14-20020a63e60e000000b003fb23692294si5960986pgh.218.2022.06.23.12.04.24; Thu, 23 Jun 2022 12:04:37 -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=UD89Tzfa; 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 S230342AbiFWRJj (ORCPT + 99 others); Thu, 23 Jun 2022 13:09:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233165AbiFWRHf (ORCPT ); Thu, 23 Jun 2022 13:07:35 -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 B900E527C4; Thu, 23 Jun 2022 09:56:18 -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 961E5B82497; Thu, 23 Jun 2022 16:56:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCA15C36AE3; Thu, 23 Jun 2022 16:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003375; bh=jOZhpB0Os0lX3o3jWLeIaLRT9vIxLW8PX+aQUJdpIjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UD89Tzfai5ad7fj01mmOhn5tp83gVv6YWXD09gUqTNudYqDcX35EnBByzxaTCPHDq lXSsNI9fwowFT0/9rKp/Hk4vEjr1JNkNgsxDXCMmBA2+Es9VFVN7k6kHlJuT88Hw/U oFjvxo/JcijUv7XsRDGzint8lSDpLpWl/xXa1RDU= 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 4.9 177/264] init: call time_init() before rand_initialize() Date: Thu, 23 Jun 2022 18:42:50 +0200 Message-Id: <20220623164349.074537039@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: "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 @@ -578,11 +578,13 @@ asmlinkage __visible void __init start_k hrtimers_init(); softirq_init(); timekeeping_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 @@ -592,7 +594,6 @@ asmlinkage __visible void __init start_k add_device_randomness(command_line, strlen(command_line)); boot_init_stack_canary(); - time_init(); sched_clock_postinit(); printk_nmi_init(); perf_event_init();