[PATCH] random: defer use of bootloader randomness to random_init()

Ard Biesheuvel ardb at kernel.org
Tue Jun 7 07:51:43 PDT 2022


On Tue, 7 Jun 2022 at 16:48, Jason A. Donenfeld <Jason at zx2c4.com> wrote:
>
> Hi Ard,
>
> On Tue, Jun 07, 2022 at 04:19:26PM +0200, Ard Biesheuvel wrote:
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <sys/random.h>
> >
> > static unsigned char buf[16];
> >
> > int main(void)
> > {
> >   for (int i = 0; i < 1000000; i++) {
> >     if (getrandom(buf, sizeof(buf),
> >         GRND_RANDOM | GRND_NONBLOCK) < sizeof(buf)) {
> >           fprintf(stderr, "getrandom() error!\n");
> >           exit(-1);
> >     }
> >   }
> >   return 0;
> > }
>
> I'm actually more worried about the random input flow than the random
> output flow and branch misprediction. But more generally, I'd just like
> to keep that code as cold as possible after crng init. It's code that's
> only used in that one phase and then never again. It can be entirely
> disabled.
>
> Anyway, we've got a few solutions now to pick from on the random.c side
> of things. I'm going to investigate the arm32 situation next. And then
> we'll see what it all looks like.
>

Sure.

It would be helpful if some other folks could chime in as well?



More information about the linux-arm-kernel mailing list