Re: [PATCH] init: call time_init() before rand_initialize()

From: Jason A. Donenfeld
Date: Sat May 07 2022 - 17:09:36 EST


Hi Andrew,

On Sat, May 07, 2022 at 12:26:53PM -0700, Andrew Morton wrote:
> On Thu, 5 May 2022 02:31:14 +0200 "Jason A. Donenfeld" <Jason@xxxxxxxxx> wrote:
>
> > Currently time_init() is called before rand_initialize(), but
>
> You mean "after"! Changelog was really confusing until I went and
> looked at the code.

Oh dear, yes. Will fix that.

>
> > rand_initialize() makes use of the timer on various platforms, and
> > sometimes this timer needs to be initialized by time_init() first. In
> > order to not return zero,
>
> return zero from what?

random_get_entropy_fallback(). I'll fix that in the commit message.

> > 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.
>
> I hope you're right. Moving these things around tends to fix one thing
> and break another.

I hope so too. Reading the platform code for every arch I can't see
where breakage would be. Nothing in the time init functions relies on
the rng being available, and actually, the rng is already quasi
functional before the call to rand_initialize(), so I think it should be
good. Nonetheless:

> No probs. Plenty of testing in linux-next, please.

Exactly this. Plus the CI on build.wireguard.com and such is churning on
it on a variety of different archs.

Jason