aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-04-16 19:59:13 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2018-04-20 12:24:02 -0400
commitb346e492d7127e4332d5a9989b844b2095cc4fcd (patch)
tree3706f0ba4529609b611134dd688b17804b86b8b1 /crypto
parent60cc43fc888428bb2f18f08997432d426a243338 (diff)
crypto: api - fix finding algorithm currently being tested
Commit eb02c38f0197 ("crypto: api - Keep failed instances alive") is making allocating crypto transforms sometimes fail with ELIBBAD, when multiple processes try to access encrypted files with fscrypt for the first time since boot. The problem is that the "request larval" for the algorithm is being mistaken for an algorithm which failed its tests. Fix it by only returning ELIBBAD for "non-larval" algorithms. Also don't leak a reference to the algorithm. Fixes: eb02c38f0197 ("crypto: api - Keep failed instances alive") Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/api.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/crypto/api.c b/crypto/api.c
index 1d5290c67108..0ee632bba064 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -204,9 +204,14 @@ static struct crypto_alg *crypto_alg_lookup(const char *name, u32 type,
204 204
205 down_read(&crypto_alg_sem); 205 down_read(&crypto_alg_sem);
206 alg = __crypto_alg_lookup(name, type | test, mask | test); 206 alg = __crypto_alg_lookup(name, type | test, mask | test);
207 if (!alg && test) 207 if (!alg && test) {
208 alg = __crypto_alg_lookup(name, type, mask) ? 208 alg = __crypto_alg_lookup(name, type, mask);
209 ERR_PTR(-ELIBBAD) : NULL; 209 if (alg && !crypto_is_larval(alg)) {
210 /* Test failed */
211 crypto_mod_put(alg);
212 alg = ERR_PTR(-ELIBBAD);
213 }
214 }
210 up_read(&crypto_alg_sem); 215 up_read(&crypto_alg_sem);
211 216
212 return alg; 217 return alg;