]> git.itanic.dy.fi Git - linux-stable/commit
random: reseed in delayed work rather than on-demand
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 17 Nov 2022 16:47:12 +0000 (17:47 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 18 Nov 2022 01:18:10 +0000 (02:18 +0100)
commit9148de3196edcba4045cfe717c8e6819fa5adeaf
tree93eb0a88b7491abc198c3c51d3352c09e67f4edb
parentd7bf7f3b813e3755226bcb5114ad2ac477514ebf
random: reseed in delayed work rather than on-demand

Currently, we reseed when random bytes are requested, if the current
seed is too old. Since random bytes can be requested from all contexts,
including hard IRQ, this means sometimes we wind up adding a bit of
latency to hard IRQ. This was so much of a problem on s390x that now
s390x just doesn't provide its architectural RNG from hard IRQ context,
so we miss out in that case.

Instead, let's just schedule a persistent delayed work, so that the
reseeding and potentially expensive operations will always happen from
process context, reducing unexpected latencies from hard IRQ.

This also has the nice effect of accumulating a transcript of random
inputs over time, since it means that we amass more input values. And it
should make future vDSO integration a bit easier.

Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Juergen Christ <jchrist@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
drivers/char/random.c