Commit 128f2bfa authored by Linus Torvalds's avatar Linus Torvalds

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
parents 35efb51e 58be0106
...@@ -772,8 +772,11 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits) ...@@ -772,8 +772,11 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits)
if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
goto retry; goto retry;
if (has_initialized) if (has_initialized) {
r->initialized = 1; r->initialized = 1;
wake_up_interruptible(&random_read_wait);
kill_fasync(&fasync, SIGIO, POLL_IN);
}
trace_credit_entropy_bits(r->name, nbits, trace_credit_entropy_bits(r->name, nbits,
entropy_count >> ENTROPY_SHIFT, _RET_IP_); entropy_count >> ENTROPY_SHIFT, _RET_IP_);
...@@ -789,6 +792,13 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits) ...@@ -789,6 +792,13 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits)
entropy_bits = r->entropy_count >> ENTROPY_SHIFT; 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? */ /* should we wake readers? */
if (entropy_bits >= random_read_wakeup_bits && if (entropy_bits >= random_read_wakeup_bits &&
wq_has_sleeper(&random_read_wait)) { wq_has_sleeper(&random_read_wait)) {
...@@ -1936,8 +1946,8 @@ _random_read(int nonblock, char __user *buf, size_t nbytes) ...@@ -1936,8 +1946,8 @@ _random_read(int nonblock, char __user *buf, size_t nbytes)
return -EAGAIN; return -EAGAIN;
wait_event_interruptible(random_read_wait, wait_event_interruptible(random_read_wait,
ENTROPY_BITS(&input_pool) >= blocking_pool.initialized &&
random_read_wakeup_bits); (ENTROPY_BITS(&input_pool) >= random_read_wakeup_bits));
if (signal_pending(current)) if (signal_pending(current))
return -ERESTARTSYS; return -ERESTARTSYS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment