Re: [PATCH v3 05/13] security/keys: ensure RNG is seeded before use

From: Jason A. Donenfeld
Date: Tue Jun 06 2017 - 08:23:18 EST


On Tue, Jun 6, 2017 at 12:08 PM, David Howells <dhowells@xxxxxxxxxx> wrote:
> Jason A. Donenfeld <Jason@xxxxxxxxx> wrote:
>
>> + key->serial = get_random_u32() >> 1;
>
> If this may sleep, it must be interruptible.

That won't sleep. I could have made it get_random_u32_wait(), but we'd
get into trouble at boottime. So instead, for now, I just use
get_random_u32 rather than get_random_bytes, which can use the
architectural random number generator, when the platform has one,
which is available early on.