diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-26 08:30:16 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-26 08:30:16 -0700 |
commit | 128f2bfafcf2e65504013934202f460a3b2e378c (patch) | |
tree | ea2eb2449397f4f60c5cc77e3bbd346a55ad8749 /drivers | |
parent | 35efb51eee2241a970dcf70ed950f9db7e5351f7 (diff) | |
parent | 58be0106c5306b939b07b4b8bf00669a20593f4b (diff) | |
download | linux-128f2bfafcf2e65504013934202f460a3b2e378c.tar.bz2 |
Merge tag 'random_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random
Pull /dev/random fix from Ted Ts'o:
"Fix a soft lockup regression when reading from /dev/random in early
boot"
* tag 'random_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random:
random: fix soft lockup when trying to read from an uninitialized blocking pool
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/random.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index a42b3d764da8..5d5ea4ce1442 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -772,8 +772,11 @@ retry: if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) goto retry; - if (has_initialized) + if (has_initialized) { r->initialized = 1; + wake_up_interruptible(&random_read_wait); + kill_fasync(&fasync, SIGIO, POLL_IN); + } trace_credit_entropy_bits(r->name, nbits, entropy_count >> ENTROPY_SHIFT, _RET_IP_); @@ -789,6 +792,13 @@ retry: entropy_bits = r->entropy_count >> ENTROPY_SHIFT; } + /* initialize the blocking pool if necessary */ + if (entropy_bits >= random_read_wakeup_bits && + !other->initialized) { + schedule_work(&other->push_work); + return; + } + /* should we wake readers? */ if (entropy_bits >= random_read_wakeup_bits && wq_has_sleeper(&random_read_wait)) { @@ -1936,8 +1946,8 @@ _random_read(int nonblock, char __user *buf, size_t nbytes) return -EAGAIN; wait_event_interruptible(random_read_wait, - ENTROPY_BITS(&input_pool) >= - random_read_wakeup_bits); + blocking_pool.initialized && + (ENTROPY_BITS(&input_pool) >= random_read_wakeup_bits)); if (signal_pending(current)) return -ERESTARTSYS; } |