Re: Chaining is dead

Milan Broz
2025-04-01T07:20:39Z

On 4/1/25 5:33 AM, Eric Biggers wrote:
> On Tue, Apr 01, 2025 at 10:44:34AM +0800, Herbert Xu wrote:
>> Thanks for the pointer, I wasn't aware of its existence. Yes
>> there should definitely be only one code path for this. So
>> what's stopping you from removing fscrypt right now? IOW what's
>> missing from blk-crypto?
>
> Well, fscrypt (ext4/f2fs/ubifs/ceph encryption) wouldn't be removed; its
> implementation would just change on ext4 and f2fs. Instead of providing a
> choice of whether to use blk-crypto or fs-layer crypto for file contents
> en/decryption, ext4 and f2fs would always use blk-crypto. Supporting code such
> as fscrypt_decrypt_bio() that would become unused by that would be removed.
>
> A few reasons I've waited so long:
>
> - The fs-layer file contents en/decryption code was there first, and there
> hasn't been a strong need to remove it yet
> - Much of the file contents en/decryption code in fs/crypto/ would still be
> needed, since ubifs and ceph still use it as they are not block-based
> - It would make CONFIG_BLK_INLINE_ENCRYPTION, which adds a field to struct bio,
> required on more systems
> - It would add the overhead of keyslot management to software crypto
> - blk-crypto currently always uses inline encryption hardware when it's
> available; but, I'd like to preserve ext4's and f2fs's existing behavior where
> the use of inline encryption hardware is opt-in via a mount option.
>
> But I'm thinking it's finally time, especially with the conversions of
> filesystems to operate on folios that's going on.
>
> dm-crypt could of course use blk-crypto too, but the dm people haven't been
> super comfortable so far with delegating en/decryption to the block layer.

Hi,

I cannot speak for device-mapper maintainers, but as it was me who complained about
block layer inline crypto introduction in dm-crypt, perhaps some clarification here:

I have no problem if there is a different block-layer/crypto API that guarantees
that the content of the bio is encrypted/decrypted, it could simplify dm-crypt a lot.
But it must not send plaintext to a random hardware device underneath by default
as it changes the dm-crypt threat model (and I see you mention the opt-in hw option
for fs mount as well).

However, dm-crypt also needs AEAD (authenticated encryption) support.
This is becoming important for devices that natively support additional per-sector metadata.
If we can access all these features through ublk in userspace one day, even better :)

Milan