]> git.baikalelectronics.ru Git - kernel.git/commit
random: mix in timestamps and reseed on system restore
authorJason A. Donenfeld <Jason@zx2c4.com>
Sun, 1 May 2022 11:51:34 +0000 (13:51 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 13 May 2022 21:59:23 +0000 (23:59 +0200)
commit272570fbfef05510f02bf6b137dc7223252afdbb
treed37773c22f6184d8731df0b27c88387bf45967b8
parent2fc3e113e981195df2ee83d95cd34cc3521c80b4
random: mix in timestamps and reseed on system restore

Since the RNG loses freshness with system suspend/hibernation, when we
resume, immediately reseed using whatever data we can, which for this
particular case is the various timestamps regarding system suspend time,
in addition to more generally the RDSEED/RDRAND/RDTSC values that happen
whenever the crng reseeds.

On systems that suspend and resume automatically all the time -- such as
Android -- we skip the reseeding on suspend resumption, since that could
wind up being far too busy. This is the same trade-off made in
WireGuard.

In addition to reseeding upon resumption always mix into the pool these
various stamps on every power notification event.

Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
drivers/char/random.c