Re: [PATCH v10 1/4] random: add vgetrandom_alloc() syscall
From: Jason A. Donenfeld
Date: Wed Nov 30 2022 - 19:18:26 EST
On Wed, Nov 30, 2022 at 10:39:38PM +0000, David Laight wrote:
> > struct vgetrandom_state {
> > union {
> > struct {
> > u8 batch[CHACHA_BLOCK_SIZE * 3 / 2];
> > u32 key[CHACHA_KEY_SIZE / sizeof(u32)];
> > };
> > u8 batch_key[CHACHA_BLOCK_SIZE * 2];
> > };
> > unsigned long generation;
> > u8 pos;
> > bool in_use;
> > };
> >
> > Plus some kernel doc which explains what this is about.
>
> That structure looks horrid - especially for something shared
> between entities.
> The 'unsigned long' should be either u32 or u64.
This struct isn't shared. It's used only by user mode code.
There may well be other issues with that long, though.
Jason