Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2950572pxk; Mon, 21 Sep 2020 01:00:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/PB4paiYF0UmvT7meozZV4WstBcRmRUVSNtqM3M2x2StY4fua8hdfnAmkTR9KHvGLBhEL X-Received: by 2002:a17:906:56c2:: with SMTP id an2mr49431338ejc.118.1600675225229; Mon, 21 Sep 2020 01:00:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600675225; cv=none; d=google.com; s=arc-20160816; b=krIh6hW2lOiQkacTB1oQE9eyMZBm/fv32wbBdhK6v0+rz9fCnLGAsF/XqhfFXYLlp0 SKcpm7twqwPNMgOdKHXE8zS2Hpd1+WfwrpYZMzDmJ4QncRKAUScim/puYuV2unjgM3gu 7+6RCpQIaCbnOWmV8waui5YisHBBCj07gNIpt677XdeeFB62crvwQ8Ih/HXLfIyqZDoA s0a76437WvYY88W2xnAHX2n1W4ir1XOTGJ9Cod3knxS55N3yrnj5L8WuO7gK69q7jsh2 g0f5zWAL+9UVkgG8S5AnFDsb5ACTPAo3WitlE7NAkipRv6b6UswHSBNr9g66nrO89qHK OXiw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NLoUSq4CzyyTywwGVKIrJJEUXYWn27rhtAzSxQdAcZE=; b=ePqD9fvpRYVM3iGrYBJymxqQ9pTgLdlZcvQvxMR7nwKQ2usS6x4wXfkNu44UNJd+BN HOQ2kganG+k3g5zjCAxvdkWyc+Aw+mnKrBPF0ILmCfpYgq5TNpt09TV5LvODVJrEfpzT n//gxo/LVUEH9vWWMlSttMYSqDCJmtVyjULUyVOjphCRAaxlFetJA+BEawxTFqQQWdme DsTs1+PRyNUANo9LTNe5EjRoM6GIdQ1QVCFTHcTx4WczFPg8/O0fQzgxGrNOC9Mv4WZI lOS8xejNQIMFdZ6jpJTsPR4vwqMDsNdCimww3G3Tdb8AlTp78QFKsZkWHyMFJBUBUxOt 2HPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e25si7708403ejb.260.2020.09.21.01.00.00; Mon, 21 Sep 2020 01:00:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726597AbgIUH7j (ORCPT + 99 others); Mon, 21 Sep 2020 03:59:39 -0400 Received: from mx2.suse.de ([195.135.220.15]:57940 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726545AbgIUH73 (ORCPT ); Mon, 21 Sep 2020 03:59:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 14EEEB51E; Mon, 21 Sep 2020 08:00:03 +0000 (UTC) From: Nicolai Stange To: "Theodore Y. Ts'o" Cc: linux-crypto@vger.kernel.org, LKML , Arnd Bergmann , Greg Kroah-Hartman , "Eric W. Biederman" , "Alexander E. Patrakov" , "Ahmed S. Darwish" , Willy Tarreau , Matthew Garrett , Vito Caputo , Andreas Dilger , Jan Kara , Ray Strode , William Jon McCann , zhangjs , Andy Lutomirski , Florian Weimer , Lennart Poettering , Peter Matthias , Marcelo Henrique Cerri , Roman Drahtmueller , Neil Horman , Randy Dunlap , Julia Lawall , Dan Carpenter , Andy Lavr , Eric Biggers , "Jason A. Donenfeld" , =?UTF-8?q?Stephan=20M=C3=BCller?= , Torsten Duwe , Petr Tesarik , Nicolai Stange Subject: [RFC PATCH 24/41] init: call time_init() before rand_initialize() Date: Mon, 21 Sep 2020 09:58:40 +0200 Message-Id: <20200921075857.4424-25-nstange@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200921075857.4424-1-nstange@suse.de> References: <20200921075857.4424-1-nstange@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Commit d55535232c3d ("random: move rand_initialize() earlier") moved the rand_initialize() invocation from the early initcalls to right after timekeeping_init(), but before time_init(). However, rand_initialize() would indirectly invoke random_get_entropy(), which is an alias to get_cycles() on most archs, in case an architectural RNG is not available. Problem is that on some archs, e.g. ARM, get_cycles() can only be relied upon when time_init() has completed. Move the invocation of time_init() a couple of lines up in start_kernel() so that it gets called before rand_initialize(). Note that random_get_entropy() data doesn't get any entropy credit and thus, this issue is not to be considered a bug, but more of an inconsistency. Fixes: d55535232c3d ("random: move rand_initialize() earlier") Signed-off-by: Nicolai Stange --- init/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/main.c b/init/main.c index ae78fb68d231..30892675f48e 100644 --- a/init/main.c +++ b/init/main.c @@ -942,6 +942,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void) hrtimers_init(); softirq_init(); timekeeping_init(); + time_init(); /* * For best initial stack canary entropy, prepare it after: @@ -956,7 +957,6 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void) add_device_randomness(command_line, strlen(command_line)); boot_init_stack_canary(); - time_init(); perf_event_init(); profile_init(); call_function_init(); -- 2.26.2