Skip to content

Commit d152fcc

Browse files
tytsogregkh
authored andcommitted
random: crng_reseed() should lock the crng instance that it is modifying
commit 0bb29a8 upstream. Reported-by: Jann Horn <jannh@google.com> Fixes: 1e7f583 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7b6b1f3 commit d152fcc

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/char/random.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
879879
_crng_backtrack_protect(&primary_crng, buf.block,
880880
CHACHA20_KEY_SIZE);
881881
}
882-
spin_lock_irqsave(&primary_crng.lock, flags);
882+
spin_lock_irqsave(&crng->lock, flags);
883883
for (i = 0; i < 8; i++) {
884884
unsigned long rv;
885885
if (!arch_get_random_seed_long(&rv) &&
@@ -889,7 +889,7 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
889889
}
890890
memzero_explicit(&buf, sizeof(buf));
891891
crng->init_time = jiffies;
892-
spin_unlock_irqrestore(&primary_crng.lock, flags);
892+
spin_unlock_irqrestore(&crng->lock, flags);
893893
if (crng == &primary_crng && crng_init < 2) {
894894
invalidate_batched_entropy();
895895
crng_init = 2;

0 commit comments

Comments
 (0)