Re: [PATCH v2] blk-crypto-fallback: Fix deadlock when encrypting large bio in dm layer

Christoph Hellwig <[email protected]>
Newsgroups org.kvack.linux-mm,org.kernel.vger.linux-block,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>
On Tue, Aug 11, 2026 at 03:03:18PM -0700, Eric Biggers wrote:
> Encrypting a large bio with more than BIO_MAX_VECS pages can still
> deadlock, even after it was attempted to be fixed by
> commit b37fbce460ad ("blk-crypto: optimize bio splitting in
> blk_crypto_fallback_encrypt_bio") and commit 3d939695e682 ("blk-crypto:
> use mempool_alloc_bulk for encrypted bio page allocation").
> 
> This is because __blk_crypto_fallback_encrypt_bio() assumes that the
> bounce bios that it submits will eventually complete, unblocking it from
> allocating additional bounce bios and pages.  However, dm-inlinecrypt.c
> calls __blk_crypto_submit_bio() from within submit_bio() itself.  In
> this case, the recursive submit_bio() simply adds the bounce bio to
> current->bio_list without actually submitting it yet.  That breaks the
> guarantee that forward progress is being made.
> 
> To fix this, allocate the bio and bounce pages with GFP_NOWAIT if
> current->bio_list is set.  If it fails, punt the encryption of the
> remaining part of the bio to a kworker.
> 
> Fixes: 488f6682c832 ("block: blk-crypto-fallback for Inline Encryption")

No, it dos not fix that commit.  I "fixes" the misguided attempt to use
this from inside stackable drivers.  Let's drop the dm-inlinecrypt
target instead as this just shows up one more reason why that is a
broken idea.

> Cc: [email protected]
> Signed-off-by: Eric Biggers <[email protected]>
> ---
> 
> Changed in v2:
> - Switched to the less efficient approach preferred by Christoph

This is in no way the approach I prefer or even advocated for.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.