Commit d152fcc1 authored by Theodore Ts'o's avatar Theodore Ts'o Committed by Greg Kroah-Hartman

random: crng_reseed() should lock the crng instance that it is modifying

commit 0bb29a84 upstream.
Reported-by: default avatarJann Horn <jannh@google.com>
Fixes: 1e7f583a ("random: make /dev/urandom scalable for silly...")
Cc: stable@kernel.org # 4.8+
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Reviewed-by: default avatarJann Horn <jannh@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7b6b1f3a
...@@ -879,7 +879,7 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r) ...@@ -879,7 +879,7 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
_crng_backtrack_protect(&primary_crng, buf.block, _crng_backtrack_protect(&primary_crng, buf.block,
CHACHA20_KEY_SIZE); CHACHA20_KEY_SIZE);
} }
spin_lock_irqsave(&primary_crng.lock, flags); spin_lock_irqsave(&crng->lock, flags);
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
unsigned long rv; unsigned long rv;
if (!arch_get_random_seed_long(&rv) && if (!arch_get_random_seed_long(&rv) &&
...@@ -889,7 +889,7 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r) ...@@ -889,7 +889,7 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
} }
memzero_explicit(&buf, sizeof(buf)); memzero_explicit(&buf, sizeof(buf));
crng->init_time = jiffies; crng->init_time = jiffies;
spin_unlock_irqrestore(&primary_crng.lock, flags); spin_unlock_irqrestore(&crng->lock, flags);
if (crng == &primary_crng && crng_init < 2) { if (crng == &primary_crng && crng_init < 2) {
invalidate_batched_entropy(); invalidate_batched_entropy();
crng_init = 2; crng_init = 2;
......
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