random: Wake up writers when random pools are zapped
diff mbox series

Message ID 20180518065736.szvspgdeyiaiqheb@gondor.apana.org.au
State New, archived
Headers show
Series
  • random: Wake up writers when random pools are zapped
Related show

Commit Message

Herbert Xu May 18, 2018, 6:57 a.m. UTC
As it is when the pool is zapped with RNDCLEARPOOL writers are
not woken up and therefore the pool may remain in the empty state
indefinitely.

This patch wakes them up unless the write threshold is set to zero.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Comments

Theodore Ts'o May 19, 2018, 9:55 p.m. UTC | #1
On Fri, May 18, 2018 at 02:57:36PM +0800, Herbert Xu wrote:
> As it is when the pool is zapped with RNDCLEARPOOL writers are
> not woken up and therefore the pool may remain in the empty state
> indefinitely.
> 
> This patch wakes them up unless the write threshold is set to zero.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Thanks, applied.

Out of curiosity, how/when were you using RNDCLEARPOOL/RNDZAPENTCNT?
Hopefully it was only testing hw_random drivers, or some such?

	     	      	      		- Ted
Herbert Xu May 20, 2018, 3:02 a.m. UTC | #2
On Sat, May 19, 2018 at 05:55:19PM -0400, Theodore Y. Ts'o wrote:
>
> Out of curiosity, how/when were you using RNDCLEARPOOL/RNDZAPENTCNT?
> Hopefully it was only testing hw_random drivers, or some such?

I wasn't actually using it myself.  Someone else filed a bug
against RHEL complaining about this and I was just clearing my
decks :)

Cheers,

Patch
diff mbox series

diff --git a/drivers/char/random.c b/drivers/char/random.c
index e027e7f..32b7010 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1874,6 +1874,10 @@  static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
 			return -EPERM;
 		input_pool.entropy_count = 0;
 		blocking_pool.entropy_count = 0;
+		if (random_write_wakeup_bits) {
+			wake_up_interruptible(&random_write_wait);
+			kill_fasync(&fasync, SIGIO, POLL_OUT);
+		}
 		return 0;
 	default:
 		return -EINVAL;