diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-01-28 23:44:03 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-02-04 19:22:32 +0100 |
commit | 042e293e16e3aa9794ce60c29f5b7b0c8170f933 (patch) | |
tree | b0f1c07c6222f4aa408dfa7aff26fbefb0bdc2db /drivers/char/random.c | |
parent | random: continually use hwgenerator randomness (diff) | |
download | linux-042e293e16e3aa9794ce60c29f5b7b0c8170f933.tar.xz linux-042e293e16e3aa9794ce60c29f5b7b0c8170f933.zip |
random: wake up /dev/random writers after zap
When account() is called, and the amount of entropy dips below
random_write_wakeup_bits, we wake up the random writers, so that they
can write some more in. However, the RNDZAPENTCNT/RNDCLEARPOOL ioctl
sets the entropy count to zero -- a potential reduction just like
account() -- but does not unblock writers. This commit adds the missing
logic to that ioctl to unblock waiting writers.
Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | drivers/char/random.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 3e133d9583a0..c336c78820cd 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1856,7 +1856,10 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg) */ if (!capable(CAP_SYS_ADMIN)) return -EPERM; - input_pool.entropy_count = 0; + if (xchg(&input_pool.entropy_count, 0) && random_write_wakeup_bits) { + wake_up_interruptible(&random_write_wait); + kill_fasync(&fasync, SIGIO, POLL_OUT); + } return 0; case RNDRESEEDCRNG: if (!capable(CAP_SYS_ADMIN)) |