summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2022-01-24 23:29:50 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2022-02-05 07:10:50 +0300
commitf4f7c153a61782f3fb259d0f39aab91444e555d9 (patch)
treef99258f1acb4bde35571a42be31a8fda9b16c224
parentf41aa47c8bb40bcbad51fc368fe15f96406897cb (diff)
downloadlinux-f4f7c153a61782f3fb259d0f39aab91444e555d9.tar.xz
hwrng: core - break out of hwrng_fillfn if current rng is not trusted
For two reasons, current_quality may become zero within the rngd kernel thread: (1) The user lowers current_quality to 0 by writing to the sysfs module parameter file (note that increasing the quality from zero is without effect at the moment), or (2) there are two or more hwrng devices registered, and those which provide quality>0 are unregistered, but one with quality==0 remains. If current_quality is 0, the randomness is not trusted and cannot help to increase the entropy count. That will lead to continuous calls to the hwrngd thread and continuous stirring of the input pool with untrusted bits. Cc: Matt Mackall <mpm@selenic.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/char/hw_random/core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 9405fcdace38..bc9f95cbac92 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -429,6 +429,9 @@ static int hwrng_fillfn(void *unused)
while (!kthread_should_stop()) {
struct hwrng *rng;
+ if (!current_quality)
+ break;
+
rng = get_current_rng();
if (IS_ERR(rng) || !rng)
break;