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: [v3 PATCH] crypto: api - fix unexpectedly getting generic implementation
Date: Wed, 4 Dec 2019 19:43:01 -0800 [thread overview]
Message-ID: <20191205034301.GA1158@sol.localdomain> (raw)
In-Reply-To: <20191205015811.mg6r3qnv7uj3fgpz@gondor.apana.org.au>
On Thu, Dec 05, 2019 at 09:58:11AM +0800, Herbert Xu wrote:
> On Wed, Dec 04, 2019 at 09:22:44AM -0800, Eric Biggers wrote:
> >
> > I was going to do something like this originally (but also checking that 'q' is
> > not "moribund", is a test larval, and has compatible cra_flags). But I don't
>
> You are right. I'll add these tests to the patch.
>
> > think it will work because a higher priority implementation could be registered
> > while a lower priority one is being instantiated and tested. Based on this
> > logic, when the lower priority implementation finishes being tested,
> > larval->adult wouldn't be set since a higher priority implementation is still
> > being tested. But then cryptomgr_probe() will complete() the larval anyway and
> > for the user crypto_alloc_foo() will fail with ENOENT.
>
> I think this is a different problem, one which we probably should
> address but it already exists regardless of what we do here. For
> example, assuming that tmpl(X) does not currently exist, and I
> request tmpl(X-generic) then tmpl(X-generic) along with X-generic
> will be created in the system. If someone then comes along and
> asks for tmpl(X) then we'll simply give them tmpl(X-generic) even
> if there exists an accelerated version of X.
>
> The problem you describe is simply a racy version of the above
> scenario where the requests for tmpl(X) and tmpl(X-generic) occur
> about the same time.
>
No, the problem I'm talking about is different and is new to your patch. If
tmpl(X-accelerated) is registered while someone is doing crypto_alg_mod_lookup()
that triggered instantiation of tmpl(X-generic), then crypto_alg_mod_lookup()
could fail with ENOENT, instead of returning tmpl(X-generic) as it does
currently. This is because the proposed new logic will not fulfill the request
larval if a better implementation of tmpl(X) is still being tested. But there's
no guarantee that tmpl(X) will finish being tested by the time cryptomgr_probe()
thinks it is done and complete()s the request larval with 'adult' still NULL.
(I think; I haven't actually tested this, this analysis is just based on my
reading of the code...)
- Eric
next prev parent reply other threads:[~2019-12-05 3:43 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 [this message]
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
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=20191205034301.GA1158@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