Re: [PATCH] random: re-add removed comment about get_random_{u32,u64} reseeding

From: Dominik Brodowski
Date: Wed Mar 23 2022 - 15:29:54 EST


Am Tue, Mar 22, 2022 at 10:23:36PM -0600 schrieb Jason A. Donenfeld:
> The comment about get_random_{u32,u64}() not invoking reseeding got
> added in an unrelated commit, that then was recently reverted. So this
> adds that little comment snippet back.
>
> Cc: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Jason A. Donenfeld <Jason@xxxxxxxxx>
> ---
> drivers/char/random.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/char/random.c b/drivers/char/random.c
> index 1d7aac2a9600..82e37d7dd9f1 100644
> --- a/drivers/char/random.c
> +++ b/drivers/char/random.c
> @@ -226,7 +226,7 @@ static void _warn_unseeded_randomness(const char *func_name, void *caller, void
> * into the given buffer or as a return value. This is equivalent to
> * a read from /dev/urandom. The integer family of functions may be
> * higher performance for one-off random integers, because they do a
> - * bit of buffering.
> + * bit of buffering and do not invoke reseeding.
> *
> *********************************************************************/

Actually, that seems wrong, as all these functions may call
_get_random_bytes(), which may invoke crng_make_state(), which
may invoke crng_reseed(). And it might be worthwhile to clarify
that it's only get_random_bytes() that does not do the bit of
buffering.

Thanks,
Dominik