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)
commitb7b67d1391a831eb9de133e85a2230e2e81a2ce4
treed37773c22f6184d8731df0b27c88387bf45967b8
parent78c768e619fbd5157b3544915aad5158af0c5809
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