btrfs: add fscrypt integration
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 Latest18 patches 9 repliesIn review
- v421 patches 4 repliesSuperseded
- v322 patches 14 repliesSuperseded
Earlier versions · 3
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 posting 2/2 | 20 patches | 46 replies | Superseded | |
| v2 RFC posting 1/2 | 16 patches | 2 replies | Superseded | |
| v1 RFC | 23 patches | 0 replies | Superseded |
Changes in v5 from the cover letter
- Added encrypting normal compressed extents.
- Dropped the first few changes, around qstr/fscrypt_str usage, since they were taken; thanks!
- Adjusted fscrypt_have_same_policy() to bubble up errors.
- Stopped using division in create_io_em().
- https://lore.kernel.org/linux-btrfs/[email protected]
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/18 | fscrypt: expose fscrypt_nokey_namefs/ include/ | +38 | 0 replies | |
| 2/18 | fscrypt: add fscrypt_have_same_policy() to check inode compatibilityfs/ include/ | +43 | 0 replies | |
| 3/18 | fscrypt: allow fscrypt_generate_iv() to distinguish filenamesfs/ fs/ | +10 | 0 replies | |
| 4/18 | fscrypt: add extent-based encryptionfs/ fs/ fs/ +2 more | +176 | 0 replies | |
| 5/18 | fscrypt: extent direct key policies for extent-based encryptionfs/ fs/ fs/ | +18 | 0 replies | |
| 6/18 | fscrypt: document btrfs' fscrypt quirks.Documentation/ | +25 | 0 replies | |
| 7/18 | btrfs: disable various operations on encrypted inodesfs/ fs/ fs/ +1 more | +17 | 0 replies | |
| 8/18 | btrfs: start using fscrypt hooksfs/ fs/ fs/ +4 more | +97 | 0 replies | |
| 9/18 | btrfs: add fscrypt_context itemsfs/ fs/ fs/ +3 more | +243 | 0 replies | |
| 10/18 | btrfs: translate btrfs encryption flags and encrypted inode flagfs/ | +11 | 0 replies | |
| 11/18 | btrfs: store a fscrypt extent context per normal file extentfs/ fs/ fs/ +12 more | +252 | 0 replies | |
| 12/18 | btrfs: encrypt normal file extent data if appropriatefs/ fs/ fs/ +1 more | +97 | 0 replies | |
| 13/18 | btrfs: Add new FEATURE_INCOMPAT_ENCRYPT feature flag.fs/ fs/ include/ | +9 | 0 replies | |
| 14/18 | btrfs: implement fscrypt ioctlsfs/ | +28 | 0 replies | |
| 15/18 | btrfs: permit searching for nokey names for removalfs/ fs/ fs/ +10 more | +319 | 0 replies | |
| 16/18 | btrfs: use correct name hash for nokey namesfs/ | +6 | 0 replies | |
| 17/18 | btrfs: encrypt verity itemsfs/ | +109 | 0 replies | |
| 18/18 | btrfs: allow encrypting compressed extentsfs/ fs/ | +23 | 0 replies |
Reviews trailers per patch
3 of 18 patches have a Reviewed-by or Acked-by.
| Patch | Josef Bacik |
|---|---|
| 1/18 | R-b |
| 2/18 | |
| 3/18 | |
| 4/18 | |
| 5/18 | |
| 6/18 | R-b |
| 7/18 | |
| 8/18 | |
| 9/18 | |
| 10/18 | R-b |
| 11/18 | |
| 12/18 | |
| 13/18 | |
| 14/18 | |
| 15/18 | |
| 16/18 | |
| 17/18 | |
| 18/18 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v5 00/18] btrfs: add fscrypt integration
This is a changeset adding encryption to btrfs.
Last October, Omar Sandoval sent out a design document for having fscrypt integration with btrfs [1]. In summary, it proposes btrfs storing its own encryption IVs on a per-file-extent basis. fscrypt usually encrypts files using an IV derived from per-inode information; this would prevent snapshotting or reflinking or data relocation for btrfs. We have refined this into a fscrypt extent context object, opaque to the filesystem, which fscrypt uses to generate an IV associated with each block in an extent. Thus, all the inodes sharing a particular key and file extent may decrypt the extent.
This series implements this integration for non-inline extents and for verity items. Followup changes will allow encryption of inline extents, which requires a few preliminary rearrangements, and will adjust tests. This series should provide encryption, but this series should not be used in production, as there are likely bugs.
This set hopefully reflects all of the feedback given on prior versions.
This patchset is based on kdave/misc-next as of a few minutes ago; 698dd8deb7c144616da2bcf2534808931a6bb8e2 .
[1]
https://lore.kernel.org/linux-btrfs/[email protected]/
Changelog:
v5:
- Added encrypting normal compressed extents.
- Dropped the first few changes, around qstr/fscrypt_str usage, since they were taken; thanks!
- Adjusted fscrypt_have_same_policy() to bubble up errors.
- Stopped using division in create_io_em().
- https://lore.kernel.org/linux-btrfs/[email protected]
v4:
- Dropped the partial directory encryption trio of patches, as it's an easy and orthogonal followon.
- fscrypt: Changed extent-based encryption to require a direct key policy.
- fscrypt: Changed to allow direct key policies with mixed filename/contents encryption modes, to enable usage of existing AES modes with btrfs.
- fscrypt: Changed terminology used for extent context contents to 'nonce' instead of 'IV', to match the nonces used in direct-key policies elsewhere.
- fscrypt: Changed IV generation for extent-based encryption to generate 16-byte IVs (if needed) from a 16-byte nonce plus extent offset, hopefully as discussed.
- fscrypt: Updated documentation change to remove partial directory encryption.
- fscrypt: Fixed another place to refer to 'inode-based' encryption instead of a more generic term.
- btrfs: Factored btrfs_fscrypt_set_extent_context() as per Josef's feedback.
- btrfs: Fixed a couple of style nits.
- https://lore.kernel.org/linux-btrfs/[email protected]
v3:
- fscrypt: changed to generate extent contexts the same way as IVs are generated for inode-based encryption, allowing use of any existing policy and making the difference in encryption more minimal.
- Changed to use qstr's, then fscrypt_strs, then fscrypt_names only where absolutely necessary, rather than fscrypt_names everywhere.
- Reordered changes to put partially-encrypted directories, and no-key name handling, in their own sections at the end of the patchset.
- Expanded on descriptions of how no-key name handling works.
- Added encryption of verity items (but see notes in change about outstanding questions there)
- Stylistic fixes
- Renamed flags from FSCRYPT to ENCRYPT in multiple instances.
- Made the incompat encrypt superblock flag be set the first time a directory is set to be encrypted, so there isn't a need for a mkfs option.
- Hopefully addressed all other minor feedback points.
- https://lore.kernel.org/linux-btrfs/[email protected]
v2:
- Amended the fscrypt side to generically add extent contexts,
hopefully as per Eric Biggers' past comments. IVs are now entirely abstracted within an extent context, and there is no longer a new encryption policy, as DIRECT_KEY sufficiently encapsulates the
needs of extent-based encryption. Documented its usage in btrfs
briefly in the documentation.
- Adjusted the btrfs side to deal in opaque extent contexts. Improved optimization to skip storing inode contexts if they are the same as
the inode's root item's inode context.
- Combined 'add fscrypt operation table to superblock' into 'start
using fscrypt hooks'.
- https://lore.kernel.org/linux-btrfs/[email protected]
- progs: https://lore.kernel.org/linux-btrfs/[email protected]
- tests: https://lore.kernel.org/linux-btrfs/[email protected]
v1:
- Recombined the fscrypt changes back into this patchset.
- Fixed several races and incorrectly ordered operations.
- Improved IV retrieval to correctly distinguish between
filename/symlink encryption and encryption of block 0 of a file.
- https://lore.kernel.org/linux-btrfs/[email protected]
- progs: https://lore.kernel.org/linux-btrfs/[email protected]
- tests: https://lore.kernel.org/linux-btrfs/[email protected]
RFC v2:
- Fixed all warnings and known incorrectnesses.
- Split fscrypt changes into their own patchset:
https://lore.kernel.org/linux-fscrypt/[email protected]
- Combined and reordered changes so that enabling fscrypt is the last change.
- Removed unnecessary factoring.
- Split a cleanup change off.
- https://lore.kernel.org/linux-btrfs/[email protected]
RFC v1:
- https://lore.kernel.org/linux-btrfs/[email protected]
Omar Sandoval (10):
fscrypt: expose fscrypt_nokey_name
fscrypt: add fscrypt_have_same_policy() to check inode compatibility
btrfs: disable various operations on encrypted inodes
btrfs: start using fscrypt hooks
btrfs: add fscrypt_context items
btrfs: translate btrfs encryption flags and encrypted inode flag
btrfs: encrypt normal file extent data if appropriate
btrfs: Add new FEATURE_INCOMPAT_ENCRYPT feature flag.
btrfs: implement fscrypt ioctls
btrfs: permit searching for nokey names for removal
Sweet Tea Dorminy (8):
fscrypt: allow fscrypt_generate_iv() to distinguish filenames
fscrypt: add extent-based encryption
fscrypt: extent direct key policies for extent-based encryption
fscrypt: document btrfs' fscrypt quirks.
btrfs: store a fscrypt extent context per normal file extent
btrfs: use correct name hash for nokey names
btrfs: encrypt verity items
btrfs: allow encrypting compressed extents
Documentation/filesystems/fscrypt.rst | 31 ++- fs/btrfs/Makefile | 1 + fs/btrfs/accessors.h | 29 +++ fs/btrfs/btrfs_inode.h | 3 +- fs/btrfs/compression.c | 23 ++ fs/btrfs/ctree.h | 4 + fs/btrfs/delayed-inode.c | 30 ++- fs/btrfs/delayed-inode.h | 4 +- fs/btrfs/dir-item.c | 81 +++++- fs/btrfs/dir-item.h | 13 +- fs/btrfs/extent_io.c | 94 ++++++- fs/btrfs/extent_io.h | 3 + fs/btrfs/extent_map.c | 7 + fs/btrfs/extent_map.h | 4 + fs/btrfs/file-item.c | 25 +- fs/btrfs/file.c | 11 +- fs/btrfs/fs.h | 5 +- fs/btrfs/fscrypt.c | 289 +++++++++++++++++++++ fs/btrfs/fscrypt.h | 64 +++++ fs/btrfs/inode.c | 358 ++++++++++++++++++++------ fs/btrfs/ioctl.c | 48 +++- fs/btrfs/ordered-data.c | 11 +- fs/btrfs/ordered-data.h | 4 +- fs/btrfs/reflink.c | 11 + fs/btrfs/root-tree.c | 8 +- fs/btrfs/root-tree.h | 2 +- fs/btrfs/super.c | 7 + fs/btrfs/tree-checker.c | 49 +++- fs/btrfs/tree-log.c | 16 +- fs/btrfs/verity.c | 124 +++++++-- fs/crypto/crypto.c | 40 ++- fs/crypto/fname.c | 43 +--- fs/crypto/fscrypt_private.h | 23 +- fs/crypto/inline_crypt.c | 28 +- fs/crypto/policy.c | 105 ++++++++ include/linux/fscrypt.h | 92 +++++++ include/uapi/linux/btrfs.h | 1 + include/uapi/linux/btrfs_tree.h | 21 ++ 38 files changed, 1509 insertions(+), 203 deletions(-) create mode 100644 fs/btrfs/fscrypt.c create mode 100644 fs/btrfs/fscrypt.h
base-commit: 698dd8deb7c144616da2bcf2534808931a6bb8e2
Signature · 1 line
2.37.3