Re: [PATCH v3] x86/coco: Require seeding RNG with RDRAND on CoCo systems

From: Dave Hansen
Date: Wed Feb 21 2024 - 18:35:35 EST


On 2/21/24 15:09, Jason A. Donenfeld wrote:
> On Wed, Feb 21, 2024 at 11:47 PM Dave Hansen <dave.hansen@xxxxxxxxx> wrote:
>> OK, so we're trying to get 256 bits of seed data from RDRAND?
>
> Yes. This fills a 32-byte buffer of longs up with output from
> arch_get_random_longs().

That's what it's doing mechanically, but what's the end goal?

>> But no pattern I could discern. Did you mean something different by
>> "platform drivers"?
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/um/kernel/um_arch.c#n413
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/char/random.c#n655

Gotcha.

> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/gcc-plugins/latent_entropy_plugin.c#n90

Isn't that one 32 HOST_WIDE_INTs and not 32 bytes? :)

>> If we're going to have arch/x86-specific crud, it would be great to make
>> it obvious and straightforward to those of us simple folk that are
>> familiar with arch/x86 code.
>
> If you insist, I'll stick a local `enum { RANDOM_BYTES_COUNT = 32 }`
> in that function or something. Seems unnecessary to me but if that's
> what you need no problem. Would that suffice? Or a different variable
> name? Or a comment on "what is 32 about?"

"what is 32 about?" would be great. What's the goal, and why is 32
enough to reach that goal?