Commit c77f8bf9 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random

Pull random fixes from Ted Ts'o:
 "Fix a circular locking dependency in random's collection of cputime
  used by a thread when it exits."

* tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random:
  random: fix locking dependency with the tasklist_lock
parents 7b54c165 b9809552
...@@ -852,6 +852,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, ...@@ -852,6 +852,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
int reserved) int reserved)
{ {
unsigned long flags; unsigned long flags;
int wakeup_write = 0;
/* Hold lock while accounting */ /* Hold lock while accounting */
spin_lock_irqsave(&r->lock, flags); spin_lock_irqsave(&r->lock, flags);
...@@ -873,10 +874,8 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, ...@@ -873,10 +874,8 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
else else
r->entropy_count = reserved; r->entropy_count = reserved;
if (r->entropy_count < random_write_wakeup_thresh) { if (r->entropy_count < random_write_wakeup_thresh)
wake_up_interruptible(&random_write_wait); wakeup_write = 1;
kill_fasync(&fasync, SIGIO, POLL_OUT);
}
} }
DEBUG_ENT("debiting %zu entropy credits from %s%s\n", DEBUG_ENT("debiting %zu entropy credits from %s%s\n",
...@@ -884,6 +883,11 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, ...@@ -884,6 +883,11 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
spin_unlock_irqrestore(&r->lock, flags); spin_unlock_irqrestore(&r->lock, flags);
if (wakeup_write) {
wake_up_interruptible(&random_write_wait);
kill_fasync(&fasync, SIGIO, POLL_OUT);
}
return nbytes; return nbytes;
} }
......
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