]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: api - fix unexpectedly getting generic implementation
authorHerbert Xu <herbert@gondor.apana.org.au>
Wed, 11 Dec 2019 02:50:11 +0000 (10:50 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 20 Dec 2019 06:58:33 +0000 (14:58 +0800)
commit7c6c932bc8a03c912cecda500e6158700cb38d69
tree4a1e278831b64d883e1c67a4d7e649f75fa7af8f
parent6bea49d9b68371b8861d26022c5100b675334223
crypto: api - fix unexpectedly getting generic implementation

When CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y, the first lookup of an
algorithm that needs to be instantiated using a template will always get
the generic implementation, even when an accelerated one is available.

This happens because the extra self-tests for the accelerated
implementation allocate the generic implementation for comparison
purposes, and then crypto_alg_tested() for the generic implementation
"fulfills" the original request (i.e. sets crypto_larval::adult).

This patch fixes this by only fulfilling the original request if
we are currently the best outstanding larval as judged by the
priority.  If we're not the best then we will ask all waiters on
that larval request to retry the lookup.

Note that this patch introduces a behaviour change when the module
providing the new algorithm is unregistered during the process.
Previously we would have failed with ENOENT, after the patch we
will instead redo the lookup.

Fixes: 05b60ef8d35e ("crypto: testmgr - fuzz hashes against...")
Fixes: ae32e500bafd ("crypto: testmgr - fuzz skciphers against...")
Fixes: 61d3e426979c ("crypto: testmgr - fuzz AEADs against...")
Reported-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/algapi.c
crypto/api.c