summaryrefslogtreecommitdiff
path: root/drivers/char/random.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2018-04-12 07:50:45 +0300
committerTheodore Ts'o <tytso@mit.edu>2018-04-14 18:59:31 +0300
commit0bb29a849a6433b72e249eea7695477b02056e94 (patch)
tree8fe433e610984789e2ffe10d0ba68fc3694afeef /drivers/char/random.c
parent8ef35c866f8862df074a49a93b0309725812dea8 (diff)
downloadlinux-0bb29a849a6433b72e249eea7695477b02056e94.tar.xz
random: crng_reseed() should lock the crng instance that it is modifying
Reported-by: Jann Horn <jannh@google.com> Fixes: 1e7f583af67b ("random: make /dev/urandom scalable for silly...") Cc: stable@kernel.org # 4.8+ Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Jann Horn <jannh@google.com>
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r--drivers/char/random.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 02d792f7933f..898233f594b4 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -906,7 +906,7 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
_crng_backtrack_protect(&primary_crng, buf.block,
CHACHA20_KEY_SIZE);
}
- spin_lock_irqsave(&primary_crng.lock, flags);
+ spin_lock_irqsave(&crng->lock, flags);
for (i = 0; i < 8; i++) {
unsigned long rv;
if (!arch_get_random_seed_long(&rv) &&
@@ -916,7 +916,7 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
}
memzero_explicit(&buf, sizeof(buf));
crng->init_time = jiffies;
- spin_unlock_irqrestore(&primary_crng.lock, flags);
+ spin_unlock_irqrestore(&crng->lock, flags);
if (crng == &primary_crng && crng_init < 2) {
invalidate_batched_entropy();
numa_crng_init();