crypto/rng: ensure that the RNG is ready before using
PATCH 1/1 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 <[email protected]>
Signed-off-by Jason A. Donenfeld <[email protected]>
--- crypto/rng.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
crypto/rng.c +4 -2
@@ -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; }
Signature · 1 line
2.13.3
Herbert Xu
maintainerQuoted 7 lines · Jason A. Donenfeld
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 <[email protected]>Signed-off-by Jason A. Donenfeld <[email protected]>
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt