summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2019-12-06 13:55:17 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-02-11 04:35:22 -0800
commitce832d16ce76b1aeb0e2fbe81aad330d2a9d1c44 (patch)
treed9104b8b7996c704ca5081b5f070165220f8962d
parent11528652a62a77fe4ba8361065114d9da1b71a29 (diff)
downloadlinux-crypto-ce832d16ce76b1aeb0e2fbe81aad330d2a9d1c44.tar.gz
linux-crypto-ce832d16ce76b1aeb0e2fbe81aad330d2a9d1c44.zip
crypto: api - Check spawn->alg under lock in crypto_drop_spawn
commit bc39d9486351deb0881a382c6c2d52b73467d304 upstream. We need to check whether spawn->alg is NULL under lock as otherwise the algorithm could be removed from under us after we have checked it and found it to be non-NULL. This could cause us to remove the spawn from a non-existent list. Fixes: d0bb12bd1529 ("crypto: api - Fix crypto_drop_spawn crash...") Cc: <stable@vger.kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--crypto/algapi.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c
index de30ddc9..b860889e 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -669,11 +669,9 @@ EXPORT_SYMBOL_GPL(crypto_grab_spawn);
void crypto_drop_spawn(struct crypto_spawn *spawn)
{
- if (!spawn->alg)
- return;
-
down_write(&crypto_alg_sem);
- list_del(&spawn->list);
+ if (spawn->alg)
+ list_del(&spawn->list);
up_write(&crypto_alg_sem);
}
EXPORT_SYMBOL_GPL(crypto_drop_spawn);