diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2019-12-06 06:55:17 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-12-11 09:48:38 +0100 |
commit | 7db3b61b6bba4310f454588c2ca6faf2958ad79f (patch) | |
tree | 531463d296fa92e7a02896dd19aeadb4dc23bcd0 /crypto/algapi.c | |
parent | crypto: chacha - fix warning message in header file (diff) | |
download | linux-7db3b61b6bba4310f454588c2ca6faf2958ad79f.tar.xz linux-7db3b61b6bba4310f454588c2ca6faf2958ad79f.zip |
crypto: api - Check spawn->alg under lock in crypto_drop_spawn
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...")
Cc: <stable@vger.kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/algapi.c')
-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 b052f38edba6..9ecb4a57b342 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); |