mirror of
https://github.com/torvalds/linux.git
synced 2025-08-15 14:11:42 +02:00
crypto: api - Redo lookup on EEXIST
When two crypto algorithm lookups occur at the same time with
different names for the same algorithm, e.g., ctr(aes-generic)
and ctr(aes), they will both be instantiated. However, only one
of them can be registered. The second instantiation will fail
with EEXIST.
Avoid failing the second lookup by making it retry, but only once
because there are tricky names such as gcm_base(ctr(aes),ghash)
that will always fail, despite triggering instantiation and EEXIST.
Reported-by: Ingo Franzki <ifranzki@linux.ibm.com>
Fixes: 2825982d9d
("[CRYPTO] api: Added event notification")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
35de409aa3
commit
0a3cf32da4
1 changed files with 11 additions and 2 deletions
13
crypto/api.c
13
crypto/api.c
|
@ -219,10 +219,19 @@ again:
|
||||||
if (crypto_is_test_larval(larval))
|
if (crypto_is_test_larval(larval))
|
||||||
crypto_larval_kill(larval);
|
crypto_larval_kill(larval);
|
||||||
alg = ERR_PTR(-ETIMEDOUT);
|
alg = ERR_PTR(-ETIMEDOUT);
|
||||||
} else if (!alg) {
|
} else if (!alg || PTR_ERR(alg) == -EEXIST) {
|
||||||
|
int err = alg ? -EEXIST : -EAGAIN;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EEXIST is expected because two probes can be scheduled
|
||||||
|
* at the same time with one using alg_name and the other
|
||||||
|
* using driver_name. Do a re-lookup but do not retry in
|
||||||
|
* case we hit a quirk like gcm_base(ctr(aes),...) which
|
||||||
|
* will never match.
|
||||||
|
*/
|
||||||
alg = &larval->alg;
|
alg = &larval->alg;
|
||||||
alg = crypto_alg_lookup(alg->cra_name, type, mask) ?:
|
alg = crypto_alg_lookup(alg->cra_name, type, mask) ?:
|
||||||
ERR_PTR(-EAGAIN);
|
ERR_PTR(err);
|
||||||
} else if (IS_ERR(alg))
|
} else if (IS_ERR(alg))
|
||||||
;
|
;
|
||||||
else if (crypto_is_test_larval(larval) &&
|
else if (crypto_is_test_larval(larval) &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue