From: Jason A. Donenfeld Date: Sun, 16 Jul 2017 17:22:06 +0000 (+0200) Subject: crypto: rng - ensure that the RNG is ready before using X-Git-Tag: v4.14-rc1~129^2~70 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c2176f0098d994050c88d34d37c551d033f2f18f;p=platform%2Fkernel%2Flinux-exynos.git crypto: rng - ensure that the RNG is ready before using Otherwise, we might be seeding the RNG using bad randomness, which is dangerous. The one use of this function from within the kernel -- not from userspace -- is being removed (keys/big_key), so that call site isn't relevant in assessing this. Cc: Herbert Xu Signed-off-by: Jason A. Donenfeld Signed-off-by: Herbert Xu --- diff --git a/crypto/rng.c b/crypto/rng.c index 5e84692..b4a6186 100644 --- a/crypto/rng.c +++ b/crypto/rng.c @@ -43,12 +43,14 @@ int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen) if (!buf) return -ENOMEM; - get_random_bytes(buf, slen); + err = get_random_bytes_wait(buf, slen); + if (err) + goto out; seed = buf; } err = crypto_rng_alg(tfm)->seed(tfm, seed, slen); - +out: kzfree(buf); return err; }