diff options
author | Theodore Ts'o <tytso@mit.edu> | 2013-03-04 11:59:12 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-03-04 12:05:15 -0500 |
commit | b980955236922ae6106774511c5c05003d3ad225 (patch) | |
tree | 3eba34d4587e58ec7b15e8fb4af5572620288fe6 /drivers/char | |
parent | 19f949f52599ba7c3f67a5897ac6be14bfcb1200 (diff) |
random: fix locking dependency with the tasklist_lock
Commit 6133705494bb introduced a circular lock dependency because
posix_cpu_timers_exit() is called by release_task(), which is holding
a writer lock on tasklist_lock, and this can cause a deadlock since
kill_fasync() gets called with nonblocking_pool.lock taken.
There's no reason why kill_fasync() needs to be taken while the random
pool is locked, so move it out to fix this locking dependency.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: Russ Dill <Russ.Dill@gmail.com>
Cc: stable@kernel.org
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/random.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 85e81ec1451e..57d4b152267c 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -852,6 +852,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, | |||
852 | int reserved) | 852 | int reserved) |
853 | { | 853 | { |
854 | unsigned long flags; | 854 | unsigned long flags; |
855 | int wakeup_write = 0; | ||
855 | 856 | ||
856 | /* Hold lock while accounting */ | 857 | /* Hold lock while accounting */ |
857 | spin_lock_irqsave(&r->lock, flags); | 858 | spin_lock_irqsave(&r->lock, flags); |
@@ -873,10 +874,8 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, | |||
873 | else | 874 | else |
874 | r->entropy_count = reserved; | 875 | r->entropy_count = reserved; |
875 | 876 | ||
876 | if (r->entropy_count < random_write_wakeup_thresh) { | 877 | if (r->entropy_count < random_write_wakeup_thresh) |
877 | wake_up_interruptible(&random_write_wait); | 878 | wakeup_write = 1; |
878 | kill_fasync(&fasync, SIGIO, POLL_OUT); | ||
879 | } | ||
880 | } | 879 | } |
881 | 880 | ||
882 | DEBUG_ENT("debiting %zu entropy credits from %s%s\n", | 881 | 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 | 883 | ||
885 | spin_unlock_irqrestore(&r->lock, flags); | 884 | spin_unlock_irqrestore(&r->lock, flags); |
886 | 885 | ||
886 | if (wakeup_write) { | ||
887 | wake_up_interruptible(&random_write_wait); | ||
888 | kill_fasync(&fasync, SIGIO, POLL_OUT); | ||
889 | } | ||
890 | |||
887 | return nbytes; | 891 | return nbytes; |
888 | } | 892 | } |
889 | 893 | ||