Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2433268ioo; Sat, 28 May 2022 13:31:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlYWZ20mrncdQdTw37o1Hw09qPoWLlb6rWPGEjfkS2Vvrz/YhRrtYGRq8GIFihw4oGIeup X-Received: by 2002:a17:902:cf0c:b0:15b:63a4:9f47 with SMTP id i12-20020a170902cf0c00b0015b63a49f47mr48629145plg.1.1653769880143; Sat, 28 May 2022 13:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653769880; cv=none; d=google.com; s=arc-20160816; b=CGV1kTl+LUp0aoJkiSJvnUwJihNoDcRRxrcWEaoXW8eYxnfDVtUwWyICbON6882Y9Q 4YNGtMoyqe+nqnjnNW8RPR1tMVx9FnL9b0j34Q+yLxg7wgvdh+2Sjv91dETh9GhlF1m8 7VdRop2AzWX+vtHRDyxYSV8n5ULGHbJEY5d75TcqmxEdM48VZhVg/wMDLi0elsNRSSA1 b7VsR2IoqhN31fUuSbolTNQP9D2qVLH3Ka33c0T6lv4ba2jGL0UnRis9EKxBLMUp1PcV t4pC7YsyKpMrFlX5SXGYgYP1F+DQhMGAiviFcw20rncuYbfrmLU5vks212sGNP8xx/Dn z61g== 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=DGiI0SENO2DS0UAJTflb0P9nE4eCZnABQhY89QPeBes=; b=K+gGqKPaAkOW0d7/rBO6coy8cxyFGb7jJPseB0IswFUj5kGG0EuqtgYs4C6Uq1AsXe ug1tRv7jktXzwn1NkWvxyik3Pd6253p59IQcTkKWHV+hqxHz+nra5Gjx1HhVmL7777DW 8I5XpFAH7x7spdAwmKYBWzEbKYnhheB1abxKRL30ajNdkrfixk4MPHjF7LRJt9hoGeU7 yOCNsXSd6GZnqspSmE7b4+YqzYLNnkDNn7hx/VqVhhX5p4CRfTQlmU9jgbgVYi32I1VU BaEpGo8gKG1JG/j/fIc/CgkrkjDb5RZ0ybw/yPiHGA11TynOm1xNzCQ4fVlsPucqr/xL LdQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wd6QJyYv; 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 q17-20020a056a00089100b0051072f6d074si12228287pfj.138.2022.05.28.13.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:31:20 -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=wd6QJyYv; 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 55D65174290; Sat, 28 May 2022 12:42:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352725AbiE0MFC (ORCPT + 99 others); Fri, 27 May 2022 08:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353271AbiE0L4W (ORCPT ); Fri, 27 May 2022 07:56:22 -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 1541BF1377; Fri, 27 May 2022 04:50:23 -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 86DFF61D9B; Fri, 27 May 2022 11:50:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95EB8C385A9; Fri, 27 May 2022 11:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653652223; bh=7YPNWX4Jl4Gp0ZD9jFSQW9lWNulhmVI61OJJWXkPpXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wd6QJyYvhR49Vu0HJQR9DjQDQVonENLzeVCwK14UQ6BL/za/W44Xebik3ZeB+3Mny NAnZqaC8KmihQYJutUScRkNEsgDxj1XjWSBMjKac05xGiAMtgOee+No87zZa+Sx+ED WLkew4WczemfTv0MP8Xn3gcxH0OjfSqMgV4j8RBE= 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.15 103/145] init: call time_init() before rand_initialize() Date: Fri, 27 May 2022 10:50:04 +0200 Message-Id: <20220527084903.081165890@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220527084850.364560116@linuxfoundation.org> References: <20220527084850.364560116@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=-1.2 required=5.0 tests=BAYES_00,DATE_IN_PAST_03_06, 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=no 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 @@ -1041,11 +1041,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 @@ -1055,7 +1057,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();