Skip to content

fscrypt: Standardize on blk-crypto

Eric Biggers linux-block linux-ext4 linux-f2fs-devel linux-fscrypt linux-fsdevel 3 versions – Applied

Status from this message: Applied to https://git.kernel.org/pub/scm/fs/fscrypt/linux.git/log/?h=for-next

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest17 patches 5 repliesApplied
  2. v217 patches 5 repliesSuperseded
  3. v116 patches 17 repliesSuperseded

Changes in v3 from the cover letter

- Fixed bug in mpage_prepare_extent_to_map().

- Updated a couple other places in fscrypt.rst.

- Cleaned up outdated comments in {ext4,f2fs}_getattr().

- Removed an orphaned function prototype.

- Fixed accidental removal of @key_type kerneldoc.

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/17blk-crypto: Simplify check for fallback supportblock/blk-crypto-fallback.c+1 -20 replies
2/17blk-crypto: Fold __blk_crypto_cfg_supported() into its callerblock/blk-crypto-internal.h block/blk-crypto-profile.c block/blk-crypto.c+21 -270 replies
3/17blk-crypto: Allow control over whether hardware is usedblock/blk-crypto.c drivers/md/dm-inlinecrypt.c fs/crypto/inline_crypt.c +1 more+27 -41 reply
4/17fscrypt: Fully disallow IV_INO_LBLK_32 with s_blocksize != PAGE_SIZEDocumentation/filesystems/fscrypt.rst fs/crypto/inline_crypt.c fs/crypto/policy.c+20 -130 replies
5/17fscrypt: Always use blk-crypto for contents on block-based filesystemsarch/loongarch/configs/loongson32_defconfig arch/loongarch/configs/loongson64_defconfig fs/crypto/Kconfig +6 more+57 -1450 replies
6/17Documentation: fscrypt: Update docs for inlinecryptDocumentation/admin-guide/ext4.rst Documentation/filesystems/f2fs.rst Documentation/filesystems/fscrypt.rst+28 -451 reply
7/17ext4: Remove fs-layer file contents en/decryption codefs/ext4/crypto.c fs/ext4/inode.c fs/ext4/page-io.c +1 more+13 -1640 replies
8/17ext4: Make ext4_bio_write_folio() return voidfs/ext4/ext4.h fs/ext4/inode.c fs/ext4/page-io.c+12 -280 replies
9/17ext4: Further de-generalize the bio postprocessing codefs/ext4/ext4.h fs/ext4/readpage.c fs/ext4/super.c+36 -390 replies
10/17f2fs: Remove fs-layer file contents en/decryption codefs/f2fs/compress.c fs/f2fs/data.c fs/f2fs/f2fs.h +2 more+12 -1170 replies
11/17fs/buffer: Remove fs-layer decryption codefs/buffer.c+8 -370 replies
12/17fscrypt: Replace calls to fscrypt_inode_uses_inline_crypto()fs/crypto/inline_crypt.c+12 -120 replies
13/17fscrypt: Remove fscrypt_dio_supported()fs/crypto/inline_crypt.c fs/ext4/inode.c fs/f2fs/file.c +1 more+3 -640 replies
14/17fscrypt: Remove fs-layer zeroout codefs/crypto/bio.c fs/crypto/crypto.c fs/crypto/fscrypt_private.h+32 -1210 replies
15/17fscrypt: Remove unused functions and workqueuefs/crypto/bio.c fs/crypto/crypto.c include/linux/fscrypt.h+0 -1440 replies
16/17fscrypt: Merge bio.c and inline_crypt.c into block.cfs/crypto/Makefile fs/crypto/bio.c fs/crypto/block.c +2 more+101 -1220 replies
17/17fscrypt: Add safety checks to non-block-based en/decryptionfs/crypto/crypto.c+39 -220 replies

Reviews trailers per patch

15 of 17 patches have a Reviewed-by or Acked-by.

PatchChristoph HellwigJan KaraChristian Brauner (Amutable)
1/17R-b
2/17R-b
3/17R-b
4/17R-b
5/17R-b
6/17R-b
7/17R-b
8/17R-b
9/17
10/17
11/17R-b R-b R-b
12/17R-b
13/17R-b
14/17R-b
15/17R-b
16/17R-b
17/17R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v3 thread

Cover letter [PATCH v3 00/17] fscrypt: Standardize on blk-crypto

This series applies to commit 2d0afaac9137e9 of
https://git.kernel.org/pub/scm/fs/fscrypt/linux.git/log/?h=for-next
It can also be retrieved from:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/ fscrypt-blk-crypto-v3

Currently, ext4 and f2fs (i.e., the block-based filesystems with fscrypt support) have two file contents encryption implementations:

- Filesystem-layer, where code in fs/crypto/ directly invokes crypto_skcipher to en/decrypt data using the CPU. This implementation requires the management of bounce pages at the filesystem level. It doesn't support direct I/O or large folios.

- blk-crypto (also known as inline encryption), where the filesystem assigns bio_crypt_ctxs to bios, which are then processed either by the CPU using blk-crypto-fallback.c or by inline encryption hardware. This supports direct I/O and is compatible with large folios.

Currently, the latter implementation is enabled only when the "inlinecrypt" mount option is given.

The persistence of the fs-layer implementation is mainly for historical reasons, as it came first. It's becoming increasingly hard to maintain, especially as the filesystems get refactored to use iomap, large folios, etc. It's time to remove it and just rely on the similar code in blk-crypto-fallback. This series does that.

Some fs-layer encryption support remains in fs/crypto/ for non-block based filesystems (UBIFS and CephFS), as well as directories and symlinks. So it's not entirely gone, but it's reduced.

To be clear, this just changes an internal implementation detail. ext4 and f2fs continue to fully support encryption (fscrypt), regardless of the presence of inline encryption hardware on the system.

Changed in v3:

- Fixed bug in mpage_prepare_extent_to_map().

- Updated a couple other places in fscrypt.rst.

- Cleaned up outdated comments in {ext4,f2fs}_getattr().

- Removed an orphaned function prototype.

- Fixed accidental removal of @key_type kerneldoc.

Changed in v2:

- Replaced the allow_hw bool with a flags argument.

- Added patch "Documentation: fscrypt: Update docs for inlinecrypt" which updates the documentation more completely by updating not just fscrypt.rst (which was previously part of another patch), but also the documentation for inlinecrypt in ext4.rst and f2fs.rst.

- Removed extern from declarations of ext4_init_verity_caches() and ext4_exit_verity_caches()

- Remove unused 'inode' argument from ext4_set_verity_work()

- Added Reviewed-by tags

Eric Biggers (17):
blk-crypto: Simplify check for fallback support
blk-crypto: Fold __blk_crypto_cfg_supported() into its caller
blk-crypto: Allow control over whether hardware is used
fscrypt: Fully disallow IV_INO_LBLK_32 with s_blocksize != PAGE_SIZE
fscrypt: Always use blk-crypto for contents on block-based filesystems
Documentation: fscrypt: Update docs for inlinecrypt
ext4: Remove fs-layer file contents en/decryption code
ext4: Make ext4_bio_write_folio() return void
ext4: Further de-generalize the bio postprocessing code
f2fs: Remove fs-layer file contents en/decryption code fs/buffer: Remove fs-layer decryption code
fscrypt: Replace calls to fscrypt_inode_uses_inline_crypto()
fscrypt: Remove fscrypt_dio_supported()
fscrypt: Remove fs-layer zeroout code
fscrypt: Remove unused functions and workqueue
fscrypt: Merge bio.c and inline_crypt.c into block.c
fscrypt: Add safety checks to non-block-based en/decryption

 Documentation/admin-guide/ext4.rst          |   8 +-
 Documentation/filesystems/f2fs.rst          |  10 +-
 Documentation/filesystems/fscrypt.rst       |  58 ++--
 arch/loongarch/configs/loongson32_defconfig |   1 -
 arch/loongarch/configs/loongson64_defconfig |   1 -
 block/blk-crypto-fallback.c                 |   3 +-
 block/blk-crypto-internal.h                 |   3 -
 block/blk-crypto-profile.c                  |  22 --
 block/blk-crypto.c                          |  34 ++-
 drivers/md/dm-inlinecrypt.c                 |   3 +-
 fs/buffer.c                                 |  45 +---
 fs/crypto/Kconfig                           |   8 +-
 fs/crypto/Makefile                          |   3 +-
 fs/crypto/bio.c                             | 216 ---------------
 fs/crypto/{inline_crypt.c => block.c}       | 284 ++++++++++----------
 fs/crypto/crypto.c                          | 140 ++++------
 fs/crypto/fscrypt_private.h                 |  28 +-
 fs/crypto/keysetup.c                        |  31 +--
 fs/crypto/policy.c                          |  17 ++
 fs/ext4/crypto.c                            |   2 +-
 fs/ext4/ext4.h                              |   6 +-
 fs/ext4/inode.c                             |  71 +----
 fs/ext4/page-io.c                           |  74 +----
 fs/ext4/readpage.c                          | 139 +++-------
 fs/ext4/super.c                             |   6 +-
 fs/f2fs/compress.c                          |  31 +--
 fs/f2fs/data.c                              |  93 +------
 fs/f2fs/f2fs.h                              |   2 -
 fs/f2fs/file.c                              |   6 +-
 fs/f2fs/segment.c                           |   2 -
 fs/f2fs/super.c                             |   2 +-
 include/linux/blk-crypto.h                  |  13 +-
 include/linux/fscrypt.h                     |  96 ++-----
 33 files changed, 387 insertions(+), 1071 deletions(-)
 delete mode 100644 fs/crypto/bio.c
 rename fs/crypto/{inline_crypt.c => block.c} (61%)

base-commit: 2d0afaac9137e95e504bd3ad3512a9044745536b

Signature · 1 line
2.55.0