diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2009-02-26 01:06:31 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2009-02-26 01:06:31 -0500 |
commit | a760a6656e6f00bb0144a42a048cf0266646e22c (patch) | |
tree | 51fffed59af5edcdd550f4517a775cba02a3d21c /crypto/api.c | |
parent | bb402f16ecf9bcdb944b8fa730f0e43cae519673 (diff) |
crypto: api - Fix module load deadlock with fallback algorithms
With the mandatory algorithm testing at registration, we have
now created a deadlock with algorithms requiring fallbacks.
This can happen if the module containing the algorithm requiring
fallback is loaded first, without the fallback module being loaded
first. The system will then try to test the new algorithm, find
that it needs to load a fallback, and then try to load that.
As both algorithms share the same module alias, it can attempt
to load the original algorithm again and block indefinitely.
As algorithms requiring fallbacks are a special case, we can fix
this by giving them a different module alias than the rest. Then
it's just a matter of using the right aliases according to what
algorithms we're trying to find.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/api.c')
-rw-r--r-- | crypto/api.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/crypto/api.c b/crypto/api.c index efe77df6863f..38a2bc02a98c 100644 --- a/crypto/api.c +++ b/crypto/api.c | |||
@@ -215,8 +215,19 @@ struct crypto_alg *crypto_larval_lookup(const char *name, u32 type, u32 mask) | |||
215 | mask &= ~(CRYPTO_ALG_LARVAL | CRYPTO_ALG_DEAD); | 215 | mask &= ~(CRYPTO_ALG_LARVAL | CRYPTO_ALG_DEAD); |
216 | type &= mask; | 216 | type &= mask; |
217 | 217 | ||
218 | alg = try_then_request_module(crypto_alg_lookup(name, type, mask), | 218 | alg = crypto_alg_lookup(name, type, mask); |
219 | name); | 219 | if (!alg) { |
220 | char tmp[CRYPTO_MAX_ALG_NAME]; | ||
221 | |||
222 | request_module(name); | ||
223 | |||
224 | if (!((type ^ CRYPTO_ALG_NEED_FALLBACK) & mask) && | ||
225 | snprintf(tmp, sizeof(tmp), "%s-all", name) < sizeof(tmp)) | ||
226 | request_module(tmp); | ||
227 | |||
228 | alg = crypto_alg_lookup(name, type, mask); | ||
229 | } | ||
230 | |||
220 | if (alg) | 231 | if (alg) |
221 | return crypto_is_larval(alg) ? crypto_larval_wait(alg) : alg; | 232 | return crypto_is_larval(alg) ? crypto_larval_wait(alg) : alg; |
222 | 233 | ||