Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6136576iog; Thu, 23 Jun 2022 12:06:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tiGaeX7uBJcl7bfCzaIXWqjkVRsaKsDXxC2FEtEn9LReOFL+bhslZlMS2UaLlpoF6jcnrF X-Received: by 2002:a05:6402:154a:b0:435:5261:f776 with SMTP id p10-20020a056402154a00b004355261f776mr12534352edx.118.1656011203877; Thu, 23 Jun 2022 12:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011203; cv=none; d=google.com; s=arc-20160816; b=0Kn/LNVrEkTVW/jUMqP8dpI3zR0zDEg6lUEFCkV92gp8tUSt658HzzLMbK90/6pcPw zvqxZMkoX4Tw5LwjVojpLEHMGrah8vgYYSdaXxQnHykf0JNExGDbjim3EjWr2GCrHsvb n2Cl/aj1Ry4vwtAq5+iPJFy08wmbcLMHGO37HquSqsZQ2DvTYnTybddCMX57YpmKgFEh opIV2l4X8yLgQcjzvKlFBVrQC7S8eEPGsx7MbpWk+RawO6KjjZ1/+SxQ1DpYbm5OXhy2 XYdbJqIY6EKQ3EpdJu1JPYNuhyQVfvKmr4CQug1mGauqVSHdygJl7cVxlJX1tyco+z38 rgMQ== 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=H+7+N6lwR/lB2sTti6k968PRXL8zrwQ8ZM52UmWm38s=; b=wJksO36d5SrrYvLsau9IKkixYeYQelGtYFss87ZIPwvmO0wZQqk5RQvYN7ta+pn8jk wHK6IKP/w9o+CUlsBHKKxGF3ira+qxvOC98rMTj9k9+kRw6+SjjThGB+04w+jJ4dY8Tf ADTPSHviNempgkz41Qo41NdwLltdBeZUCnwBXvImafXtSQ/kLa6DqEt79icZE7d7B+4i oPYOBtsoI6E0RSl8huHL0clVYf74ci/c4J35pDPXYF5MYb9I7K6boebrN0XIfHavVMJ8 bB+UkfHbiOQsieOzIdCrKW73CDH5HOE29Q3Tu9ytCNNdQlKBig6I2QOgEZ+e1DhXHiH/ Ir0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fVWqy77c; 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 i12-20020a1709064fcc00b007175ffc8bcfsi1883530ejw.922.2022.06.23.12.06.17; Thu, 23 Jun 2022 12:06:43 -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=fVWqy77c; 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 S233276AbiFWSIt (ORCPT + 99 others); Thu, 23 Jun 2022 14:08:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235929AbiFWSGj (ORCPT ); Thu, 23 Jun 2022 14:06:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40FB888B2D; Thu, 23 Jun 2022 10:18:58 -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 C9C74B824B8; Thu, 23 Jun 2022 17:18:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23F75C341CC; Thu, 23 Jun 2022 17:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004735; bh=yrB08dOo2r9eU21gJ0zuxMRdsCTQI5T0Kpy/n87Izaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fVWqy77cej4k6gzyEjYiNle/yPKc7vf5I/Lg31hKPZWj549qIfvv6Z6IC+srhCzA9 lCxn6oCCefCxKHr7bRKejF5CD5Degb1Pt+Np4FLVzarrlQynI7Lnv+Mo2kS4HOdFJ/ x0wDs51ACUhrcjsXFDoLMX8WY6G4u/NHWtaEeSDo= 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.19 134/234] init: call time_init() before rand_initialize() Date: Thu, 23 Jun 2022 18:43:21 +0200 Message-Id: <20220623164346.849705766@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 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 @@ -633,11 +633,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 @@ -647,7 +649,6 @@ asmlinkage __visible void __init start_k add_device_randomness(command_line, strlen(command_line)); boot_init_stack_canary(); - time_init(); perf_event_init(); profile_init(); call_function_init();