random: re-add removed comment about get_random_{u32,u64} reseeding
Jason A. Donenfeld
maintainerPATCH 1/1 random: re-add removed comment about get_random_{u32,u64} reseeding
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.
--- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/random.c +1 -1
@@ -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. * *********************************************************************/
Signature · 1 line
2.35.1
Am Tue, Mar 22, 2022 at 10:23:36PM -0600 schrieb Jason A. Donenfeld:
Quoted 15 lines
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 <[email protected]>Signed-off-by Jason A. Donenfeld <[email protected]>--- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/random.c +0
-0
drivers/char/random.c static void _warn_unseeded_randomness(const char *func_name, void *caller, void · line 231
Quoted 7 lines
drivers/char/random.c +1
-1@@ -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
Jason A. Donenfeld
maintainerHi Dominik,
Good point; might as well take this opportunity to firm up that wording. How about:
"... and do not invoke reseeding until the buffer is emptied."
Jason
Am Wed, Mar 23, 2022 at 01:45:22PM -0600 schrieb Jason A. Donenfeld:
Quoted 6 lines
Hi Dominik,
Good point; might as well take this opportunity to firm up that wording. How about:
"... and do not invoke reseeding until the buffer is emptied."
Yes, that sounds better. Though "integer family of functions" still sounds a bit ambiguous.
Thanks,
Dominik
Jason A. Donenfeld
maintainerPATCH v2 1/1 random: re-add removed comment about get_random_{u32,u64} reseeding
The comment about get_random_{u32,u64}() not invoking reseeding got added in an unrelated commit, that then was recently reverted by 0313bc278dac ("Revert "random: block in /dev/urandom""). So this adds that little comment snippet back, and improves the wording a bit too.
--- drivers/char/random.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/char/random.c +4 -3
@@ -224,9 +224,10 @@ static void _warn_unseeded_randomness(const char *func_name, void *caller, void* * These interfaces will return the requested number of random bytes * 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. +* a read from /dev/urandom. The u32, u64, int, and long family of +* functions may be higher performance for one-off random integers, +* because they do a bit of buffering and do not invoke reseeding +* until the buffer is emptied. * *********************************************************************/
Signature · 1 line
2.35.1
Am Wed, Mar 23, 2022 at 02:10:18PM -0600 schrieb Jason A. Donenfeld:
Quoted 7 lines
The comment about get_random_{u32,u64}() not invoking reseeding got added in an unrelated commit, that then was recently reverted by
0313bc278dac("Revert "random: block in/dev/urandom""). So this adds that little comment snippet back, and improves the wording a bit too.Cc Dominik Brodowski <[email protected]>Signed-off-by Jason A. Donenfeld <[email protected]>