From: sashiko-bot@kernel.org
To: "Laveesh Bansal" <laveeshb@laveeshbansal.com>,
"Jens Axboe" <axboe@kernel.dk>,
"Eric Biggers" <ebiggers@kernel.org>
Cc: "Christoph Hellwig" <hch@lst.de>,
"Theodore Y. Ts'o" <tytso@mit.edu>,
"Jaegeuk Kim" <jaegeuk@kernel.org>,
syzbot+20d60aafd9a0d1f2a380@syzkaller.appspotmail.com,
linux-fscrypt@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: Re: [PATCH] blk-crypto: avoid fs reclaim under profile->lock in the fallback
Date: Sun, 22 Nov 2026 21:44:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-228362@kernel.org> (raw)
In-Reply-To: <20261122213120.20974-1-laveeshb@laveeshbansal.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] block: NULL deref and OOB read in blk-crypto-fallback with
num_keyslots=0 [1]
--
commit 7d0d16db31e8a22572290b726bc65b670e7fa101
Author: Laveesh Bansal <laveeshb@laveeshbansal.com>
blk-crypto: avoid fs reclaim under profile->lock in the fallback
This commit wraps the crypto_sync_skcipher_setkey() calls in the blk-crypto
fallback with memalloc_noio_save() to prevent direct reclaim from recursing
into filesystem key eviction while holding profile->lock.
> diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c
> index 12e0b487e23ab..2df418f169328 100644
> --- a/block/blk-crypto-fallback.c
> +++ b/block/blk-crypto-fallback.c
> @@ -89,17 +89,24 @@ static struct bio_set enc_bio_set;
> */
> static u8 blank_key[BLK_CRYPTO_MAX_RAW_KEY_SIZE];
>
> +/*
> + * setkey can allocate while profile->lock is held, and reclaim takes that lock
> + * to evict a key. Use NOIO so those allocations can't recurse into the fs.
> + */
> static void blk_crypto_fallback_evict_keyslot(unsigned int slot)
> {
> struct blk_crypto_fallback_keyslot *slotp = &blk_crypto_keyslots[slot];
[Severity: High]
This problem wasn't introduced by this patch, but can setting the
num_keyslots module parameter to 0 cause an out-of-bounds read here and a
NULL pointer dereference in blk_crypto_keyslot_index() [1]?
When profile->num_slots is 0, __blk_crypto_evict_key() invokes
keyslot_evict() with slot set to -1, which blk_crypto_fallback_evict_keyslot()
uses as an unsigned index into the zero-length blk_crypto_keyslots[] array:
block/blk-crypto-profile.c:__blk_crypto_evict_key() {
if (profile->num_slots == 0) {
if (profile->ll_ops.keyslot_evict) {
blk_crypto_hw_enter(profile);
err = profile->ll_ops.keyslot_evict(profile, key, -1);
blk_crypto_hw_exit(profile);
return err;
}
return 0;
}
}
Similarly, during encryption with num_slots == 0, blk_crypto_get_keyslot()
returns BLK_STS_OK with *slot_ptr = NULL, and
blk_crypto_fallback_encrypt_bio() -> blk_crypto_fallback_tfm() ->
blk_crypto_keyslot_index() dereferences slot->profile.
[1] https://sashiko.dev/#/bug/linux-3e1346dd-cfa2-4a1f-89e7-2cad97d10dce
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261122213120.20974-1-laveeshb@laveeshbansal.com?part=1
next prev parent reply other threads:[~2026-11-22 21:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 21:31 [PATCH] blk-crypto: avoid fs reclaim under profile->lock in the fallback Laveesh Bansal
2026-11-22 21:44 ` sashiko-bot [this message]
2026-11-23 9:31 ` 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=sashiko-outbox-228362@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=axboe@kernel.dk \
--cc=ebiggers@kernel.org \
--cc=hch@lst.de \
--cc=jaegeuk@kernel.org \
--cc=laveeshb@laveeshbansal.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=syzbot+20d60aafd9a0d1f2a380@syzkaller.appspotmail.com \
--cc=tytso@mit.edu \
/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