Skip to content

Commit 042e293

Browse files
committed
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 <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent c321e90 commit 042e293

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/char/random.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,10 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
18561856
*/
18571857
if (!capable(CAP_SYS_ADMIN))
18581858
return -EPERM;
1859-
input_pool.entropy_count = 0;
1859+
if (xchg(&input_pool.entropy_count, 0) && random_write_wakeup_bits) {
1860+
wake_up_interruptible(&random_write_wait);
1861+
kill_fasync(&fasync, SIGIO, POLL_OUT);
1862+
}
18601863
return 0;
18611864
case RNDRESEEDCRNG:
18621865
if (!capable(CAP_SYS_ADMIN))

0 commit comments

Comments
 (0)