mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] random: re-add removed comment about get_random_{u32,u64} reseeding
@ 2022-03-23  4:23 Jason A. Donenfeld
  2022-03-23 19:24 ` Dominik Brodowski
  0 siblings, 1 reply; 6+ messages in thread
From: Jason A. Donenfeld @ 2022-03-23  4:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jason A. Donenfeld, Dominik Brodowski

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@dominikbrodowski.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 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.
  *
  *********************************************************************/
 
-- 
2.35.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] random: re-add removed comment about get_random_{u32,u64} reseeding
  2022-03-23  4:23 [PATCH] random: re-add removed comment about get_random_{u32,u64} reseeding Jason A. Donenfeld
@ 2022-03-23 19:24 ` Dominik Brodowski
  2022-03-23 19:45   ` Jason A. Donenfeld
  0 siblings, 1 reply; 6+ messages in thread
From: Dominik Brodowski @ 2022-03-23 19:24 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: linux-kernel

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@dominikbrodowski.net>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] random: re-add removed comment about get_random_{u32,u64} reseeding
  2022-03-23 19:24 ` Dominik Brodowski
@ 2022-03-23 19:45   ` Jason A. Donenfeld
  2022-03-23 19:51     ` Dominik Brodowski
  0 siblings, 1 reply; 6+ messages in thread
From: Jason A. Donenfeld @ 2022-03-23 19:45 UTC (permalink / raw)
  To: Dominik Brodowski; +Cc: LKML

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."

Jason

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] random: re-add removed comment about get_random_{u32,u64} reseeding
  2022-03-23 19:45   ` Jason A. Donenfeld
@ 2022-03-23 19:51     ` Dominik Brodowski
  2022-03-23 20:10       ` [PATCH v2] " Jason A. Donenfeld
  0 siblings, 1 reply; 6+ messages in thread
From: Dominik Brodowski @ 2022-03-23 19:51 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: LKML


Am Wed, Mar 23, 2022 at 01:45:22PM -0600 schrieb Jason A. Donenfeld:
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] random: re-add removed comment about get_random_{u32,u64} reseeding
  2022-03-23 19:51     ` Dominik Brodowski
@ 2022-03-23 20:10       ` Jason A. Donenfeld
  2022-03-24  5:10         ` Dominik Brodowski
  0 siblings, 1 reply; 6+ messages in thread
From: Jason A. Donenfeld @ 2022-03-23 20:10 UTC (permalink / raw)
  To: linux, linux-kernel; +Cc: Jason A. Donenfeld

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 <linux@dominikbrodowski.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 drivers/char/random.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 1d7aac2a9600..40107f8b9e9e 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -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.
  *
  *********************************************************************/
 
-- 
2.35.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] random: re-add removed comment about get_random_{u32,u64} reseeding
  2022-03-23 20:10       ` [PATCH v2] " Jason A. Donenfeld
@ 2022-03-24  5:10         ` Dominik Brodowski
  0 siblings, 0 replies; 6+ messages in thread
From: Dominik Brodowski @ 2022-03-24  5:10 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: linux-kernel

Am Wed, Mar 23, 2022 at 02:10:18PM -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 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 <linux@dominikbrodowski.net>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

	Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-03-24  5:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23  4:23 [PATCH] random: re-add removed comment about get_random_{u32,u64} reseeding Jason A. Donenfeld
2022-03-23 19:24 ` Dominik Brodowski
2022-03-23 19:45   ` Jason A. Donenfeld
2022-03-23 19:51     ` Dominik Brodowski
2022-03-23 20:10       ` [PATCH v2] " Jason A. Donenfeld
2022-03-24  5:10         ` Dominik Brodowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®