Re: [PATCH v2] x86, random: Fix get_random_bytes() warning in x86 start_kernel

From: Theodore Y. Ts'o
Date: Fri Feb 01 2019 - 22:02:53 EST


On Fri, Feb 01, 2019 at 01:08:31PM -0500, Prarit Bhargava wrote:
> After 43838a23a05f ("random: fix crng_ready() test") early boot calls to
> get_random_bytes() will warn on x86 because the crng is not initialized.
> For example,
>
> random: get_random_bytes called from start_kernel+0x8e/0x587 with crng_init=0
>
> x86 only uses get_random_bytes() for better randomization of the stack
> canary value so the warning is of no consequence.
>
> Test if the crng is initialized before calling get_random_bytes(). If it
> is not available then attempt to read from the hardware random generator,
> before finally using the TSC.

If you want to trust the CPU's hardware number generator, there is a
way to do this already. Simply enable CONFIG_RANDOM_TRUST_CPU, or set
the boot command line option "random.trust_cpu=on".

Also, relying on the TSC for entropy is not something we should be
recommending.

So, NAK.

- Ted