From: Eric Biggers <ebiggers@kernel.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
linux-fscrypt@vger.kernel.org,
Nathan Huckleberry <nhuck@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v2 2/4] blk-crypto: make blk_crypto_evict_key() more robust
Date: Wed, 15 Mar 2023 11:26:58 -0700 [thread overview]
Message-ID: <20230315182658.GB975@sol.localdomain> (raw)
In-Reply-To: <ZBHw8DteTQq6p97i@infradead.org>
On Wed, Mar 15, 2023 at 09:23:12AM -0700, Christoph Hellwig wrote:
> On Wed, Mar 08, 2023 at 11:36:43AM -0800, Eric Biggers wrote:
> > const struct blk_crypto_key *key)
> > @@ -389,22 +377,22 @@ int __blk_crypto_evict_key(struct blk_crypto_profile *profile,
> >
> > blk_crypto_hw_enter(profile);
> > slot = blk_crypto_find_keyslot(profile, key);
> > + if (slot) {
>
> Isn't !slot also an error condition that we should warn on?
No, definitely not. Keys are not guaranteed to be in a keyslot. I'll add a
comment here.
>
> > + if (WARN_ON_ONCE(atomic_read(&slot->slot_refs) != 0)) {
> > + /* BUG: key is still in use by I/O */
> > + err = -EBUSY;
>
> Either way two gotos to jump forward for the error case would improve
> the readability of the code a fair bit I think.
I slightly prefer it without the gotos, but sure I'll do it that way.
> > + } else {
> > + err = profile->ll_ops.keyslot_evict(
> > + profile, key,
> > + blk_crypto_keyslot_index(slot));
> > + }
> > + /*
> > + * Callers may free the key even on error, so unlink the key
> > + * from the hash table and clear slot->key even on error.
> > + */
> > + hlist_del(&slot->hash_node);
> > + slot->key = NULL;
> > }
> > blk_crypto_hw_exit(profile);
> > return err;
>
> Also given your above accurate description of the calling context,
> what is the point of even returning an error here vs just logging
> an error message?
Yes, I was thinking about that too. I'll add a patch that makes
blk_crypto_evict_key() log errors and return void.
- Eric
next prev parent reply other threads:[~2023-03-15 18:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 19:36 [PATCH v2 0/4] Fix blk-crypto keyslot race condition Eric Biggers
2023-03-08 19:36 ` [PATCH v2 1/4] blk-mq: release crypto keyslot before reporting I/O complete Eric Biggers
2023-03-13 21:26 ` Nathan Huckleberry
2023-03-14 18:20 ` Eric Biggers
2023-03-15 16:18 ` Christoph Hellwig
2023-03-15 16:19 ` Christoph Hellwig
2023-03-08 19:36 ` [PATCH v2 2/4] blk-crypto: make blk_crypto_evict_key() more robust Eric Biggers
2023-03-15 16:23 ` Christoph Hellwig
2023-03-15 18:26 ` Eric Biggers [this message]
2023-03-08 19:36 ` [PATCH v2 3/4] blk-crypto: remove blk_crypto_insert_cloned_request() Eric Biggers
2023-03-15 16:24 ` Christoph Hellwig
2023-03-15 18:27 ` Eric Biggers
2023-03-08 19:36 ` [PATCH v2 4/4] blk-crypto: drop the NULL check from blk_crypto_put_keyslot() Eric Biggers
2023-03-15 16:24 ` Christoph Hellwig
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=20230315182658.GB975@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=nhuck@google.com \
--cc=stable@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.