summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorStephan Müller <smueller@chronox.de>2020-06-07 15:20:26 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-06-22 14:11:18 +0200
commite9eb0c4741a70e8f361452f675b6acc07cef20b8 (patch)
treeb8deeb0eadfce785394959ba72bb147bf6f5d626 /crypto
parentf284afc3a9ca60f06306ad18554a1c434f093e99 (diff)
downloadlinux-stable-e9eb0c4741a70e8f361452f675b6acc07cef20b8.tar.gz
linux-stable-e9eb0c4741a70e8f361452f675b6acc07cef20b8.tar.bz2
linux-stable-e9eb0c4741a70e8f361452f675b6acc07cef20b8.zip
crypto: drbg - always try to free Jitter RNG instance
commit 819966c06b759022e9932f328284314d9272b9f3 upstream. The Jitter RNG is unconditionally allocated as a seed source follwoing the patch 97f2650e5040. Thus, the instance must always be deallocated. Reported-by: syzbot+2e635807decef724a1fa@syzkaller.appspotmail.com Fixes: 97f2650e5040 ("crypto: drbg - always seeded with SP800-90B ...") Signed-off-by: Stephan Mueller <smueller@chronox.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/drbg.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/drbg.c b/crypto/drbg.c
index 28871b0896ea..b2b256a1c52e 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1647,10 +1647,12 @@ static int drbg_uninstantiate(struct drbg_state *drbg)
if (drbg->random_ready.notifier_call) {
unregister_random_ready_notifier(&drbg->random_ready);
cancel_work_sync(&drbg->seed_work);
- crypto_free_rng(drbg->jent);
- drbg->jent = NULL;
}
+ if (!IS_ERR_OR_NULL(drbg->jent))
+ crypto_free_rng(drbg->jent);
+ drbg->jent = NULL;
+
if (drbg->d_ops)
drbg->d_ops->crypto_fini(drbg);
drbg_dealloc_state(drbg);