linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans-Christian Noren Egtvedt <hegtvedt@cisco.com>
To: linux-kernel@vger.kernel.org
Cc: gregkh@linuxfoundation.org, Kees Cook <keescook@chromium.org>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Hans-Christian Noren Egtvedt <hegtvedt@cisco.com>
Subject: [v4.9 PATCH v2 6/6] random: move rand_initialize() earlier
Date: Mon,  1 Aug 2022 18:43:28 +0200	[thread overview]
Message-ID: <20220801164328.2205839-6-hegtvedt@cisco.com> (raw)
In-Reply-To: <20220801164328.2205839-1-hegtvedt@cisco.com>

From: Kees Cook <keescook@chromium.org>

Right now rand_initialize() is run as an early_initcall(), but it only
depends on timekeeping_init() (for mixing ktime_get_real() into the
pools). However, the call to boot_init_stack_canary() for stack canary
initialization runs earlier, which triggers a warning at boot:

random: get_random_bytes called from start_kernel+0x357/0x548 with crng_init=0

Instead, this moves rand_initialize() to after timekeeping_init(), and moves
canary initialization here as well.

Note that this warning may still remain for machines that do not have
UEFI RNG support (which initializes the RNG pools during setup_arch()),
or for x86 machines without RDRAND (or booting without "random.trust=on"
or CONFIG_RANDOM_TRUST_CPU=y).

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
(cherry picked from commit d55535232c3dbde9a523a9d10d68670f5fe5dec3)
Signed-off-by: Hans-Christian Noren Egtvedt <hegtvedt@cisco.com>

Adjusted to fit on top of linux-4.9.y branch, suspecting a wrongly
solved conflict when cherry picked earlier.
---
 init/main.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/init/main.c b/init/main.c
index 6bc1a3fa152..6537f51a0ba 100644
--- a/init/main.c
+++ b/init/main.c
@@ -500,13 +500,6 @@ asmlinkage __visible void __init start_kernel(void)
 	page_address_init();
 	pr_notice("%s", linux_banner);
 	setup_arch(&command_line);
-	/*
-	 * Set up the the initial canary and entropy after arch
-	 * and after adding latent and command line entropy.
-	 */
-	add_latent_entropy();
-	add_device_randomness(command_line, strlen(command_line));
-	boot_init_stack_canary();
 	mm_init_cpumask(&init_mm);
 	setup_command_line(command_line);
 	setup_nr_cpu_ids();
-- 
2.34.1


  parent reply	other threads:[~2022-08-01 16:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01 16:43 [v4.9 PATCH v2 1/6] include/uapi/linux/swab.h: fix userspace breakage, use __BITS_PER_LONG for swap Hans-Christian Noren Egtvedt
2022-08-01 16:43 ` [v4.9 PATCH v2 2/6] init/main: Fix double "the" in comment Hans-Christian Noren Egtvedt
2022-08-01 16:43 ` [v4.9 PATCH v2 3/6] init/main: properly align the multi-line comment Hans-Christian Noren Egtvedt
2022-08-01 16:43 ` [v4.9 PATCH v2 4/6] init: move stack canary initialization after setup_arch Hans-Christian Noren Egtvedt
2022-08-01 16:43 ` [v4.9 PATCH v2 5/6] init/main.c: extract early boot entropy from the passed cmdline Hans-Christian Noren Egtvedt
2022-08-01 16:43 ` Hans-Christian Noren Egtvedt [this message]
2022-08-03 12:07   ` [v4.9 PATCH v2 6/6] random: move rand_initialize() earlier Greg KH
2022-08-03 14:01     ` [v4.9 PATCH v3 6/6] random: only call boot_init_stack_canary() once Hans-Christian Noren Egtvedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220801164328.2205839-6-hegtvedt@cisco.com \
    --to=hegtvedt@cisco.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).