]> git.baikalelectronics.ru Git - kernel.git/commit
random: add mechanism for VM forks to reinitialize crng
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 23 Feb 2022 12:43:44 +0000 (13:43 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Sun, 13 Mar 2022 01:00:56 +0000 (18:00 -0700)
commitb9f5e8b72a9f3381b37a0ac109b1092ab26f746a
treef548673becb7e4fc9baa0372b6a96edd87eb43f7
parent59c566aa536e3208f7ed10f646b60d9916934748
random: add mechanism for VM forks to reinitialize crng

When a VM forks, we must immediately mix in additional information to
the stream of random output so that two forks or a rollback don't
produce the same stream of random numbers, which could have catastrophic
cryptographic consequences. This commit adds a simple API, add_vmfork_
randomness(), for that, by force reseeding the crng.

This has the added benefit of also draining the entropy pool and setting
its timer back, so that any old entropy that was there prior -- which
could have already been used by a different fork, or generally gone
stale -- does not contribute to the accounting of the next 256 bits.

Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Jann Horn <jannh@google.com>
Cc: Eric Biggers <ebiggers@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
drivers/char/random.c
include/linux/random.h