Re: [PATCH] blk-crypto: avoid fs reclaim under profile->lock in the fallback

From: Christoph Hellwig

Date: Mon Nov 23 2026 - 04:31:49 EST


On Sun, Nov 22, 2026 at 01:31:20PM -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.
>
> Use memalloc_noio_save() around both setkey calls (keyslot_program and
> the blank-key clear in evict_keyslot), as blk_crypto_alloc_enc_bio()
> does.

Pleawe move these into blk_crypto_hw_enter/exit so that it is tied
to the lock for which you enforce the NOIO context instead of hacking
around the issue for specific allocations.