All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org
Subject: Re: [PATCH v3 0/7] Fix bio splitting by the crypto fallback code
Date: Fri, 18 Jul 2025 09:50:24 -0700	[thread overview]
Message-ID: <20250718165024.GD1574@quark> (raw)
In-Reply-To: <3d6e8317-7697-4bb4-8462-c67b5e6683b4@acm.org>

On Fri, Jul 18, 2025 at 08:37:04AM -0700, Bart Van Assche wrote:
> On 7/16/25 9:43 PM, Christoph Hellwig wrote:
> > Getting back to this.  While the ton is a bit snarky, it brings up a good
> > point.  Relying on the block layer to ensure that data is always
> > encrypted seems like a bad idea, given that is really not what the block
> > layer is about, and definitively not high on the mind of anyone touching
> > the code.  So I would not want to rely on the block layer developers to
> > ensure that data is encrypted properly through APIs not one believes part
> > that mission.
> > 
> > So I think you'd indeed be much better off not handling the (non-inline)
> > incryption in the block layer.
> > 
> > Doing that in fact sounds pretty easy - instead of calling the
> > blk-crypto-fallback code from inside the block layer, call it from the
> > callers instead of submit_bio when inline encryption is not actually
> > supported, e.g.
> > 
> > 	if (!blk_crypto_config_supported(bdev, &crypto_cfg))
> > 		blk_crypto_fallback_submit_bio(bio);
> > 	else
> > 		submit_bio(bio);
> > 
> > combined with checks in the low-level block code that we never get a
> > crypto context into the low-level submission into ->submit_bio or
> > ->queue_rq when not supported.
> > 
> > That approach not only is much easier to verify for correct encryption
> > operation, but also makes things like bio splitting and the required
> > memory allocation for it less fragile.
> 
> Has it ever been considered to merge the inline encryption code into
> dm-crypt or convert the inline encryption fallback code into a new dm
> driver? If user space code would insert a dm device between filesystems
> and block devices if hardware encryption is not supported that would
> have the following advantages:
> * No filesystem implementations would have to be modified.
> * It would make it easier to deal with bio splitting since dm drivers
>   can set stacking limits in their .io_hints() callback.

Yes, this was considered back when blk-crypto-fallback was being added.
But it is useful to support blk-crypto unconditionally without userspace
having to set up a dm device:

- It allows testing the inline encryption code paths in ext4 and f2fs
  with xfstests on any system, just by adding the inlinecrypt mount
  option.  See e.g.
  https://lore.kernel.org/linux-block/20191031205045.GG16197@mit.edu/
  and 
  https://lore.kernel.org/linux-block/20200515170059.GA1009@sol.localdomain/

- It allows upper layers to just use blk-crypto instead of having both
  blk-crypto and non-blk-crypto code paths.  While I've been late on
  converting fscrypt to actually rely on this, it still might be a good
  idea, especially as we now need to revisit the code for reasons like
  large folio support.  (And Christoph seems to support this too -- see
  https://lore.kernel.org/linux-block/20250715062112.GC18672@lst.de/)

But, as suggested at
https://lore.kernel.org/linux-block/20250717044342.GA26995@lst.de/ it
should also be okay to reorganize things so that the regular
submit_bio() does not support the fallback, and upper layers have to
call a different function blk_crypto_fallback_submit_bio() if they want
the fallback.  I don't think that would help with the splitting issue
directly, but perhaps we could make the filesystems just not submit bios
that would need splitting by blk-crypto-fallback, which would solve the
issue.

- Eric

  reply	other threads:[~2025-07-18 16:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-15 20:10 [PATCH v3 0/7] Fix bio splitting by the crypto fallback code Bart Van Assche
2025-07-15 20:10 ` [PATCH v3 1/7] block: Improve blk_crypto_fallback_split_bio_if_needed() Bart Van Assche
2025-07-16 11:49   ` John Garry
2025-07-16 17:20     ` Bart Van Assche
2025-07-15 20:10 ` [PATCH v3 2/7] block: Split blk_crypto_fallback_split_bio_if_needed() Bart Van Assche
2025-07-15 20:10 ` [PATCH v3 3/7] block: Modify the blk_crypto_bio_prep() calling convention Bart Van Assche
2025-07-15 20:10 ` [PATCH v3 4/7] block: Modify the blk_crypto_fallback_bio_prep() " Bart Van Assche
2025-07-15 20:10 ` [PATCH v3 5/7] block: Change the blk_crypto_fallback_encrypt_bio() " Bart Van Assche
2025-07-15 20:10 ` [PATCH v3 6/7] block: Rework splitting of encrypted bios Bart Van Assche
2025-07-15 20:10 ` [PATCH v3 7/7] block, crypto: Remove crypto_bio_split Bart Van Assche
2025-07-15 21:44 ` [PATCH v3 0/7] Fix bio splitting by the crypto fallback code Eric Biggers
2025-07-15 22:35   ` Bart Van Assche
2025-07-16  1:14     ` Eric Biggers
2025-07-16 11:25   ` Christoph Hellwig
2025-07-17  4:43   ` Christoph Hellwig
2025-07-17 17:58     ` Bart Van Assche
2025-07-18  8:17       ` Christoph Hellwig
2025-07-18 15:37     ` Bart Van Assche
2025-07-18 16:50       ` Eric Biggers [this message]
2025-07-21  6:01         ` Christoph Hellwig
2025-07-16 16:12 ` Bart Van Assche

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=20250718165024.GD1574@quark \
    --to=ebiggers@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.