diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2019-12-06 13:55:17 +0800 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2020-05-22 21:19:16 +0100 |
commit | 45079caf08e16ef7ed9c0bca9dab09725c017a0d (patch) | |
tree | 24d4fc91741f5d18a15aded9860117454ee717b1 | |
parent | cbc787163f47eb86a385cf20397c04e13293dd60 (diff) | |
download | linux-stable-45079caf08e16ef7ed9c0bca9dab09725c017a0d.tar.gz |
crypto: api - Check spawn->alg under lock in crypto_drop_spawn
commit 7db3b61b6bba4310f454588c2ca6faf2958ad79f 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: 7ede5a5ba55a ("crypto: api - Fix crypto_drop_spawn crash...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | crypto/algapi.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index 300cafd2228d99..89d0cde501f2b8 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -618,11 +618,9 @@ EXPORT_SYMBOL_GPL(crypto_init_spawn2); 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); |