Skip to content

RFC Consolidate Post read processing code

Chandan Rajendra linux-ext4 linux-f2fs-devel linux-fscrypt linux-fsdevel 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 RFC Latest14 patches 0 repliesNew
  2. v1 RFC14 patches 0 repliesSuperseded

Changes in v2 from the cover letter

1. Describe the purpose of "Post processing code" in the cover letter.
2. Fix build errors when CONFIG_FS_VERITY is enabled.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14ext4: Clear BH_Uptodate flag on decryption errorfs/ext4/inode.c+6 -20 replies
2/14Consolidate "post read processing" into a new filefs/Makefile fs/crypto/bio.c fs/crypto/crypto.c +10 more+220 -3360 replies
3/14fsverity: Add call back to decide if verity check has to be performedfs/ext4/super.c fs/post_read_process.c include/linux/fsverity.h+10 -10 replies
4/14fsverity: Add call back to determine readpage limitfs/ext4/super.c include/linux/fsverity.h+19 -00 replies
5/14fs/mpage.c: Integrate post read processingfs/mpage.c+48 -30 replies
6/14ext4: Wire up ext4_readpage[s] to use mpage_readpage[s]fs/ext4/Makefile fs/ext4/inode.c fs/ext4/readpage.c+3 -2990 replies
7/14Remove the term "bio" from post read processingfs/crypto/bio.c fs/f2fs/data.c fs/mpage.c +3 more+52 -520 replies
8/14Add decryption support for sub-pagesized blocksfs/buffer.c fs/crypto/bio.c fs/crypto/crypto.c +5 more+154 -610 replies
9/14ext4: Decrypt all boundary blocks when doing buffered writefs/ext4/inode.c+23 -100 replies
10/14ext4: Decrypt the block that needs to be partially zeroedfs/ext4/inode.c+3 -20 replies
11/14fscrypt_encrypt_page: Loop across all blocks mapped by a page rangefs/crypto/crypto.c+25 -120 replies
12/14ext4: Compute logical block and the page range to be encryptedfs/ext4/page-io.c+7 -20 replies
13/14fscrypt_zeroout_range: Encrypt all zeroed out blocks of a pagefs/crypto/bio.c+18 -220 replies
14/14ext4: Enable encryption for subpage-sized blocksDocumentation/filesystems/fscrypt.rst fs/ext4/super.c+2 -90 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [RFC PATCH V2 00/14] Consolidate Post read processing code

This patchset moves the "post read processing" code into a file of its own (i.e. fs/post_read_process.c) and modifies the generic do_mpage_readpge() to make use of the functionality provided.

"Post read processing" implements code to track the state machine that needs to be executed after reading data from files that are encrypted and/or have verity metadata associated with them.

With these changes in place, the patchset changes Ext4 to use mpage_readpage[s] instead of its own custom ext4_readpage[s]() functions. This is done to reduce duplicity of code across filesystems. Also, Post read processing source files will be built only if one of CONFIG_FS_ENCRYPTION and CONFIG_FS_VERITY is enabled.

Members of "struct fscrypt_ctx" that tracked status of a "write" operation are now made an anonymous structure since the decryption state tracking members are now moved into "struct post_read_ctx".

The patchset also modifies fs/buffer.c and fscrypt functionality to get file encryption/decryption to work with subpage-sized blocks.

The following fixes from Eric Biggers are prerequisites for this patchset,
fscrypt: fix race where ->lookup() marks plaintext dentry as ciphertext
fscrypt: only set dentry_operations on ciphertext dentries
fscrypt: clear DCACHE_ENCRYPTED_NAME when unaliasing directory
fscrypt: fix race allowing rename() and link() of ciphertext dentries
fscrypt: clean up and improve dentry revalidation

The patches can also be obtained from, "https://github.com/chandanr/linux.git subpage-encryption"

TODO:
1. The subset of the fscrypt_encrypt_page() that deals with FS_CFLG_OWN_PAGES case still needs to be tested. UBIFS seems to be the only user of this piece of code.
2. Verity changes needs to be added for F2FS and I will add them in the next patchset based on the review comments obtained for the current patchset.

Changelog:
RFC V1 -> RFC V2:
1. Describe the purpose of "Post processing code" in the cover letter.
2. Fix build errors when CONFIG_FS_VERITY is enabled.

Chandan Rajendra (14):
ext4: Clear BH_Uptodate flag on decryption error Consolidate "post read processing" into a new file
fsverity: Add call back to decide if verity check has to be performed
fsverity: Add call back to determine readpage limit fs/mpage.c: Integrate post read processing
ext4: Wire up ext4_readpage[s] to use mpage_readpage[s] Remove the term "bio" from post read processing
Add decryption support for sub-pagesized blocks
ext4: Decrypt all boundary blocks when doing buffered write
ext4: Decrypt the block that needs to be partially zeroed
fscrypt_encrypt_page: Loop across all blocks mapped by a page range
ext4: Compute logical block and the page range to be encrypted
fscrypt_zeroout_range: Encrypt all zeroed out blocks of a page
ext4: Enable encryption for subpage-sized blocks

 Documentation/filesystems/fscrypt.rst |   4 +-
 fs/Makefile                           |   4 +
 fs/buffer.c                           |  85 +++--
 fs/crypto/bio.c                       | 109 ++++---
 fs/crypto/crypto.c                    |  73 +++--
 fs/crypto/fscrypt_private.h           |   3 +
 fs/ext4/Makefile                      |   2 +-
 fs/ext4/ext4.h                        |   2 -
 fs/ext4/inode.c                       |  47 ++-
 fs/ext4/page-io.c                     |   9 +-
 fs/ext4/readpage.c                    | 445 --------------------------
 fs/ext4/super.c                       |  40 ++-
 fs/f2fs/data.c                        | 148 ++-------
 fs/f2fs/super.c                       |   9 +-
 fs/mpage.c                            |  51 ++-
 fs/post_read_process.c                | 155 +++++++++
 fs/verity/verify.c                    |  12 +
 include/linux/buffer_head.h           |   1 +
 include/linux/fscrypt.h               |  20 +-
 include/linux/fsverity.h              |   2 +
 include/linux/post_read_process.h     |  22 ++
 21 files changed, 511 insertions(+), 732 deletions(-)
 delete mode 100644 fs/ext4/readpage.c
 create mode 100644 fs/post_read_process.c
 create mode 100644 include/linux/post_read_process.h
Signature · 1 line
2.19.1