diff options
| author | Eric Biggers <ebiggers@kernel.org> | 2026-07-12 22:36:56 -0400 |
|---|---|---|
| committer | Eric Biggers <ebiggers@kernel.org> | 2026-07-20 10:39:25 -0700 |
| commit | 5acc6f649a687526bd42c4242098a2582689587b (patch) | |
| tree | 9647aecc3e01c3e08a2babbd554872515a16feb3 /fs/ext4 | |
| parent | b69664873f4af302c7867aa7478e818549932614 (diff) | |
| download | linux-next-5acc6f649a687526bd42c4242098a2582689587b.tar.gz linux-next-5acc6f649a687526bd42c4242098a2582689587b.zip | |
fscrypt: Always use blk-crypto for contents on block-based filesystems
For encrypting and decrypting file contents on block-based filesystems
(i.e., ext4 and f2fs, but not ceph and ubifs), always use blk-crypto
instead of fs-layer crypto (direct use of crypto_skcipher).
Since the blk-crypto API provides a fallback to CPU-based encryption,
it's all that's needed on block-based filesystems. The support for two
alternative block-based file contents encryption implementations,
fs-layer and blk-crypto, existed mainly for historical reasons, as the
fs-layer path came first. Some of it is also still needed for the
non-block-based filesystems, but a lot of it isn't.
Removing the duplicate fs-layer code paths greatly simplifies the code,
most of which is done in later commits.
Specific implementation details:
- SB_INLINECRYPT now controls whether blk_crypto_config::allow_hw is set
to true, instead of whether blk-crypto is used at all. The effect is
that the semantics are preserved: the inlinecrypt mount option selects
the use of inline encryption hardware instead of the CPU.
- Set up a blk_crypto_key iff the file is a regular file on a
block-based filesystem. To determine whether the filesystem is
block-based, add a bit fscrypt_operations::is_block_based.
- Remove fscrypt_select_encryption_impl(). Move the logging logic that
was previously there into fscrypt_prepare_inline_crypt_key(). Note
that blk_crypto_config_supported() is no longer needed.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20260713023708.9245-6-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Diffstat (limited to 'fs/ext4')
| -rw-r--r-- | fs/ext4/crypto.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c index f41f320f4437..6b809ac80ef7 100644 --- a/fs/ext4/crypto.c +++ b/fs/ext4/crypto.c @@ -236,6 +236,7 @@ static bool ext4_has_stable_inodes(struct super_block *sb) const struct fscrypt_operations ext4_cryptops = { .inode_info_offs = (int)offsetof(struct ext4_inode_info, i_crypt_info) - (int)offsetof(struct ext4_inode_info, vfs_inode), + .is_block_based = 1, .needs_bounce_pages = 1, .has_32bit_inodes = 1, .supports_subblock_data_units = 1, |
