crypto: api - Check spawn->alg under lock in crypto_drop_spawn
authorHerbert Xu <herbert@gondor.apana.org.au>
Fri, 6 Dec 2019 05:55:17 +0000 (13:55 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Feb 2020 21:31:00 +0000 (16:31 -0500)
commit1d6bd3f50ebb1898972180649ee2845d606f87f2
treef1aab352da511e1d90afdc94b09529b4854f078c
parent8ff8c1e1d0fad2495392c884a88db8a245ad6663
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...")
Cc: <stable@vger.kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
crypto/algapi.c