crypto: api - Fix race condition in crypto_spawn_alg
authorHerbert Xu <herbert@gondor.apana.org.au>
Sat, 7 Dec 2019 14:15:15 +0000 (22:15 +0800)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 22 May 2020 20:19:16 +0000 (21:19 +0100)
commit523433150b46ea50e434a32909554e11d7b215b5
tree5f03ad50fa576a269aa68eca265b91f057eafef2
parent45079caf08e16ef7ed9c0bca9dab09725c017a0d
crypto: api - Fix race condition in crypto_spawn_alg

commit 73669cc556462f4e50376538d77ee312142e8a8a upstream.

The function crypto_spawn_alg is racy because it drops the lock
before shooting the dying algorithm.  The algorithm could disappear
altogether before we shoot it.

This patch fixes it by moving the shooting into the locked section.

Fixes: 6bfd48096ff8 ("[CRYPTO] api: Added spawns")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
crypto/algapi.c
crypto/api.c
crypto/internal.h