From: Eric Biggers <ebiggers@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, pvanleeuwen@verimatrix.com
Subject: Re: [v5 PATCH] crypto: api - fix unexpectedly getting generic implementation
Date: Tue, 10 Dec 2019 19:15:34 -0800 [thread overview]
Message-ID: <20191211031534.GC732@sol.localdomain> (raw)
In-Reply-To: <20191211025010.advtedzhazvx52ij@gondor.apana.org.au>
On Wed, Dec 11, 2019 at 10:50:11AM +0800, Herbert Xu wrote:
> On Tue, Dec 10, 2019 at 06:26:13PM -0800, Eric Biggers wrote:
> >
> > Sorry, I didn't notice you had already sent another patch for this. I think
> > this patch is okay, except that it's broken because it doesn't actually do
> > anything with the 'r' variable in crypto_alg_tested(). I suggest just removing
>
> Oops.
>
> > that variable and doing:
> >
> > if (best && crypto_mod_get(alg))
> > larval->adult = alg;
> > else
> > larval->adult = ERR_PTR(-EAGAIN);
>
> OK I have made this change.
>
> > Also, it would be nice to also add a function comment for crypto_alg_tested(),
> > like I had in my original patch. It's hard to understand this code.
>
> Your original comments no longer apply but if you wish to make
> another patch to add more comments that would certainly be welcome.
>
> Thanks,
>
> ---8<---
> 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: 9a8a6b3f0950 ("crypto: testmgr - fuzz hashes against...")
> Fixes: d435e10e67be ("crypto: testmgr - fuzz skciphers against...")
> Fixes: 40153b10d91c ("crypto: testmgr - fuzz AEADs against...")
> Reported-by: Eric Biggers <ebiggers@google.com>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Looks good, thanks.
Reviewed-by: Eric Biggers <ebiggers@google.com>
- Eric
next prev parent reply other threads:[~2019-12-11 3:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-02 22:13 [PATCH] crypto: api - fix unexpectedly getting generic implementation Eric Biggers
2019-12-03 11:44 ` Ard Biesheuvel
2019-12-04 9:19 ` [v2 PATCH] " Herbert Xu
2019-12-04 17:22 ` Eric Biggers
2019-12-05 1:58 ` [v3 " Herbert Xu
2019-12-05 3:43 ` Eric Biggers
2019-12-05 4:55 ` [v4 " Herbert Xu
2019-12-11 2:26 ` Eric Biggers
2019-12-11 2:50 ` [v5 " Herbert Xu
2019-12-11 3:15 ` Eric Biggers [this message]
2019-12-05 4:04 ` [v3 " Eric Biggers
2019-12-05 4:23 ` Herbert Xu
2019-12-05 4:27 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191211031534.GC732@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=pvanleeuwen@verimatrix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox