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

Eric Biggers <[email protected]>
Newsgroups gmane.linux.block,gmane.linux.kernel.mm,gmane.linux.kernel,gmane.linux.kernel.stable
Message-ID <[email protected]>
On Thu, Aug 13, 2026 at 11:34:49PM -0700, Christoph Hellwig wrote:
> 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.

It is what you asked for on v1 and you've now changed your position, as
far as I can tell.  I can change the Fixes commit to e7f57d2c47e2.
dm-inlinecrypt is useful and it does not make sense to drop it.

- Eric
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.