From 7383439ef6a0ecd23843c2fec22e2221e3d64dc3 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 6 Jan 2019 12:46:06 -0800 Subject: [PATCH] crypto: algapi - reject NULL crypto_spawn::inst commit 6b476662b09c393936e0f62c97ad9988d410fd36 upstream It took me a while to notice the bug where the adiantum template left crypto_spawn::inst == NULL, because this only caused problems in certain cases where algorithms are dynamically loaded/unloaded. More improvements are needed, but for now make crypto_init_spawn() reject this case and WARN(), so this type of bug will be noticed immediately in the future. Note: I checked all callers and the adiantum template was the only place that had this wrong. So this WARN shouldn't trigger anymore. Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Zou Cao Reviewed-by: luanshi Acked-by: Caspar Zhang --- crypto/algapi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crypto/algapi.c b/crypto/algapi.c index c0755cf4f53f..33eb6e73eff1 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -599,6 +599,9 @@ int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg, { int err = -EAGAIN; + if (WARN_ON_ONCE(inst == NULL)) + return -EINVAL; + spawn->inst = inst; spawn->mask = mask; -- GitLab