From: Eric Biggers <ebiggers@kernel.org>
To: Nathan Huckleberry <nhuck@google.com>
Cc: linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
linux-fscrypt@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 2/3] blk-crypto: make blk_crypto_evict_key() more robust
Date: Fri, 3 Mar 2023 19:50:08 +0000 [thread overview]
Message-ID: <ZAJPcMibOQ9DARmp@gmail.com> (raw)
In-Reply-To: <CAJkfWY7KNcJwLKST6TefRZ6TyFNd6C1LXo_tD2yWGdVMjmsOtA@mail.gmail.com>
On Fri, Mar 03, 2023 at 11:45:00AM -0800, Nathan Huckleberry wrote:
> > int __blk_crypto_evict_key(struct blk_crypto_profile *profile,
> > 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)
> > - goto out_unlock;
> > -
> > - if (WARN_ON_ONCE(atomic_read(&slot->slot_refs) != 0)) {
> > - err = -EBUSY;
> > - goto out_unlock;
> > + if (slot) {
> > + if (WARN_ON_ONCE(atomic_read(&slot->slot_refs) != 0)) {
> > + /* BUG: key is still in use by I/O */
> > + err = -EBUSY;
> > + } 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;
> > }
>
> The !slot case still needs to be handled. If profile->num_slots != 0
> and !slot, we'll get an invalid index from blk_crypto_keyslot_index.
>
> With that change,
> Reviewed-by: Nathan Huckleberry <nhuck@google.com>
>
> Thanks,
> Huck
>
> > - err = profile->ll_ops.keyslot_evict(profile, key,
> > - blk_crypto_keyslot_index(slot));
> > - if (err)
> > - goto out_unlock;
> > -
> > - hlist_del(&slot->hash_node);
> > - slot->key = NULL;
> > - err = 0;
> > -out_unlock:
> > blk_crypto_hw_exit(profile);
> > return err;
> > }
I'm not sure what you're referring to. The !slot case is handled correctly, and
it's the same as before.
- Eric
next prev parent reply other threads:[~2023-03-03 19:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230303071959.144604-1-ebiggers@kernel.org>
2023-03-03 7:19 ` [PATCH 1/3] blk-mq: release crypto keyslot before reporting I/O complete Eric Biggers
2023-03-03 19:29 ` Nathan Huckleberry
2023-03-08 18:21 ` Eric Biggers
2023-03-03 7:19 ` [PATCH 2/3] blk-crypto: make blk_crypto_evict_key() more robust Eric Biggers
2023-03-03 19:45 ` Nathan Huckleberry
2023-03-03 19:50 ` Eric Biggers [this message]
2023-03-03 20:30 ` Nathan Huckleberry
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=ZAJPcMibOQ9DARmp@gmail.com \
--to=ebiggers@kernel.org \
--cc=axboe@kernel.dk \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox