Re: [PATCH v3] blk-crypto: use a NOIO scope while holding profile->lock

From: Eric Biggers

Date: Fri Nov 27 2026 - 13:48:18 EST


On Wed, Nov 25, 2026 at 12:14:17AM -0800, Laveesh Bansal wrote:
> Setting a key in blk-crypto-fallback can deadlock on profile->lock.
> blk_crypto_get_keyslot() holds it across keyslot_program, whose setkey
> allocates with GFP_KERNEL (Adiantum); direct reclaim can evict an fscrypt
> inode, and blk_crypto_evict_key() then takes profile->lock again. syzbot
> reports it as an fs_reclaim vs profile->lock cycle. Since
> commit 5acc6f649a68 ("fscrypt: Always use blk-crypto for contents on
> block-based filesystems") hitting it no longer needs -o inlinecrypt.
>
> Enter a NOIO scope in blk_crypto_hw_enter() and leave it in
> blk_crypto_hw_exit(), so allocations made under the lock, by the
> fallback or a hardware driver, can't recurse into I/O or fs reclaim.
> blk_crypto_reprogram_all_keys() takes the lock directly, so it gets the
> same scope.
>
> Fixes: 488f6682c832 ("block: blk-crypto-fallback for Inline Encryption")
> Cc: stable@xxxxxxxxxxxxxxx
> Reported-by: syzbot+20d60aafd9a0d1f2a380@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://lore.kernel.org/r/6a9b25c3.b5d4176b.238c3e.0004.GAE@xxxxxxxxxx
> Suggested-by: Christoph Hellwig <hch@xxxxxx>
> Signed-off-by: Laveesh Bansal <laveeshb@xxxxxxxxxxxxxxxxx>

Reviewed-by: Eric Biggers <ebiggers@xxxxxxxxxx>

- Eric