Skip to content

Commit

Permalink
crypto: api - Check spawn->alg under lock in crypto_drop_spawn
Browse files Browse the repository at this point in the history
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: 7ede5a5 ("crypto: api - Fix crypto_drop_spawn crash...")
Cc: <stable@vger.kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Herbert Xu committed Dec 11, 2019
1 parent 579d705 commit 7db3b61
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions crypto/algapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7db3b61

Please sign in to comment.