All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] random: only wake up writers after zap if threshold was passed
@ 2022-02-22 13:05 Jason A. Donenfeld
  2022-02-24  7:48 ` Dominik Brodowski
  0 siblings, 1 reply; 2+ messages in thread
From: Jason A. Donenfeld @ 2022-02-22 13:05 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jason A. Donenfeld, Dominik Brodowski, Theodore Ts'o

The only time that we need to wake up /dev/random writers on
RNDCLEARPOOL/RNDZAPPOOL is when we're changing from a value that is
greater than or equal to POOL_MIN_BITS to zero, because if we're
changing from below POOL_MIN_BITS to zero, the writers are already
unblocked.

Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Theodore Ts'o <tytso@mit.edu>
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 a4dedeea35e9..536237a0f073 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1582,7 +1582,7 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
 		 */
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-		if (xchg(&input_pool.entropy_count, 0)) {
+		if (xchg(&input_pool.entropy_count, 0) >= POOL_MIN_BITS) {
 			wake_up_interruptible(&random_write_wait);
 			kill_fasync(&fasync, SIGIO, POLL_OUT);
 		}
-- 
2.35.1


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

* Re: [PATCH] random: only wake up writers after zap if threshold was passed
  2022-02-22 13:05 [PATCH] random: only wake up writers after zap if threshold was passed Jason A. Donenfeld
@ 2022-02-24  7:48 ` Dominik Brodowski
  0 siblings, 0 replies; 2+ messages in thread
From: Dominik Brodowski @ 2022-02-24  7:48 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: linux-kernel, Theodore Ts'o

Am Tue, Feb 22, 2022 at 02:05:03PM +0100 schrieb Jason A. Donenfeld:
> The only time that we need to wake up /dev/random writers on
> RNDCLEARPOOL/RNDZAPPOOL is when we're changing from a value that is
> greater than or equal to POOL_MIN_BITS to zero, because if we're
> changing from below POOL_MIN_BITS to zero, the writers are already
> unblocked.
> 
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Cc: Theodore Ts'o <tytso@mit.edu>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

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

Thanks,
	Dominik

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

end of thread, other threads:[~2022-02-24  7:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 13:05 [PATCH] random: only wake up writers after zap if threshold was passed Jason A. Donenfeld
2022-02-24  7:48 ` Dominik Brodowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.