diff mbox

random: Wake up all getrandom(2) callers when pool is ready

Message ID 20150521081953.GA22301@gondor.apana.org.au (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Herbert Xu May 21, 2015, 8:19 a.m. UTC
On Thu, May 21, 2015 at 09:55:17AM +0200, Stephan Mueller wrote:
>
> So, I will create a 2nd wait queue in random.c for uninterruptible waits, 
> change the get_blocking_random_bytes back to void and use wait_event to wait 
> for the initialization.

Hold your horses.  You don't need a second queue, you just need to
change wake_up_interruptible to wake_up.

Hmm, in fact shouldn't this be wake_up_all? Otherwise what are the
other getrandom(2) callers going to do? Ted?

---8<---
If more than one application invokes getrandom(2) before the pool
is ready, then all bar one will be stuck forever because we use
wake_up_interruptible which wakes up a single task.

This patch replaces it with wake_up_all.

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


Cheers,

Comments

Stephan Mueller May 21, 2015, 8:36 a.m. UTC | #1
Am Donnerstag, 21. Mai 2015, 16:19:54 schrieb Herbert Xu:

Hi Herbert,

>On Thu, May 21, 2015 at 09:55:17AM +0200, Stephan Mueller wrote:
>> So, I will create a 2nd wait queue in random.c for uninterruptible waits,
>> change the get_blocking_random_bytes back to void and use wait_event to
>> wait
>> for the initialization.
>
>Hold your horses.  You don't need a second queue, you just need to
>change wake_up_interruptible to wake_up.

A simple change to wake_up is not working -- I already checked. But the 
proposed wake_up_all does the trick.


Ciao
Stephan
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o May 21, 2015, 7:17 p.m. UTC | #2
On Thu, May 21, 2015 at 04:19:54PM +0800, Herbert Xu wrote:
> On Thu, May 21, 2015 at 09:55:17AM +0200, Stephan Mueller wrote:
> >
> > So, I will create a 2nd wait queue in random.c for uninterruptible waits, 
> > change the get_blocking_random_bytes back to void and use wait_event to wait 
> > for the initialization.
> 
> Hold your horses.  You don't need a second queue, you just need to
> change wake_up_interruptible to wake_up.
> 
> Hmm, in fact shouldn't this be wake_up_all? Otherwise what are the
> other getrandom(2) callers going to do? Ted?

Yes, this should definitely be wake_up_all()

							- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Herbert Xu May 22, 2015, 12:23 a.m. UTC | #3
On Thu, May 21, 2015 at 03:17:39PM -0400, Theodore Ts'o wrote:
>
> Yes, this should definitely be wake_up_all()

Thanks for the confirmation.  Can I push this patch through the
cryptodev tree since Stephan's work is probably going to depend
on it?

Cheers,
diff mbox

Patch

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 9cd6968..8b8c46b 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -660,7 +660,7 @@  retry:
 		r->entropy_total = 0;
 		if (r == &nonblocking_pool) {
 			prandom_reseed_late();
-			wake_up_interruptible(&urandom_init_wait);
+			wake_up_all(&urandom_init_wait);
 			pr_notice("random: %s pool is initialized\n", r->name);
 		}
 	}