]> 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)
commit54872951b840f5c9d9c0eb6773a972bdc0ec1e16
treed37773c22f6184d8731df0b27c88387bf45967b8
parentdd751af60e0b5aff69bd863e0b9c0cfcc618a84b
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