Skip to content

btrfs: add fscrypt integration

Sweet Tea Dorminy linux-btrfs linux-fscrypt 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest21 patches 4 repliesIn review

Changes in v1 from the cover letter

- 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]

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/21fscrypt: expose fscrypt_nokey_namefs/crypto/fname.c include/linux/fscrypt.h+38 -380 replies
2/21fscrypt: add flag allowing partially-encrypted directoriesfs/crypto/fname.c include/linux/fscrypt.h+18 -10 replies
3/21fscrypt: add fscrypt_have_same_policy() to check inode's compatibilityfs/crypto/policy.c include/linux/fscrypt.h+27 -00 replies
4/21fscrypt: add a function for a filesystem to generate an IVfs/crypto/crypto.c include/linux/fscrypt.h+29 -00 replies
5/21fscrypt: add new encryption policy for btrfs.fs/crypto/crypto.c fs/crypto/fscrypt_private.h fs/crypto/inline_crypt.c +4 more+73 -124 replies
6/21btrfs: store directorys' encryption statefs/btrfs/ctree.h fs/btrfs/delayed-inode.c fs/btrfs/delayed-inode.h +7 more+43 -270 replies
7/21btrfs: use fscrypt_name's instead of name/len everywhere.fs/btrfs/ctree.h fs/btrfs/delayed-inode.c fs/btrfs/delayed-inode.h +14 more+518 -3870 replies
8/21btrfs: setup fscrypt_names from dentrys using helperfs/btrfs/inode.c fs/btrfs/transaction.c fs/btrfs/tree-log.c+123 -680 replies
9/21btrfs: factor a fscrypt_name matching methodfs/btrfs/Makefile fs/btrfs/dir-item.c fs/btrfs/extent_io.c +6 more+116 -200 replies
10/21btrfs: disable various operations on encrypted inodesfs/btrfs/btrfs_inode.h fs/btrfs/file.c fs/btrfs/inode.c +1 more+14 -30 replies
11/21btrfs: add fscrypt operation table to superblockfs/btrfs/fscrypt.c fs/btrfs/fscrypt.h fs/btrfs/super.c+7 -00 replies
12/21btrfs: start using fscrypt hooks.fs/btrfs/ctree.h fs/btrfs/file.c fs/btrfs/inode.c+83 -120 replies
13/21btrfs: add fscrypt_context items.fs/btrfs/ctree.h fs/btrfs/fscrypt.c fs/btrfs/inode.c +3 more+221 -10 replies
14/21btrfs: translate btrfs encryption flags and encrypted inode flag.fs/btrfs/ioctl.c+11 -20 replies
15/21btrfs: add iv generation function for fscryptfs/btrfs/fscrypt.c+12 -00 replies
16/21btrfs: store an IV per encrypted normal file extentfs/btrfs/ctree.h fs/btrfs/extent_map.h fs/btrfs/file-item.c +9 more+189 -290 replies
17/21btrfs: Add new FEATURE_INCOMPAT_FSCRYPT feature flag.fs/btrfs/ctree.h include/uapi/linux/btrfs.h+5 -20 replies
18/21btrfs: reuse encrypted filename hash when possible.fs/btrfs/ctree.h+18 -30 replies
19/21btrfs: adapt directory read and lookup to potentially encrypted filenamesfs/btrfs/delayed-inode.c fs/btrfs/delayed-inode.h fs/btrfs/dir-item.c +1 more+134 -150 replies
20/21btrfs: encrypt normal file extent data if appropriatefs/btrfs/extent_io.c fs/btrfs/file-item.c fs/btrfs/fscrypt.c +2 more+97 -250 replies
21/21btrfs: implement fscrypt ioctlsfs/btrfs/ioctl.c+28 -00 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 00/21] 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, but by using an IV associated with each file extent, all the inodes sharing a particular key and file extent may decrypt successfully.

This series implements this integration for the simple case, non-compressed data extents. Followup changes will allow encryption of compressed extents, inline extents, and verity items. This series should provide encryption for the simplest cases, but this series should not be used except for testing yet, as there are likely bugs particularly around IV retrieval.

Preliminary btrfs-progs changes are available at [2]; fstests changes are available at [3]. Additional tests around subvolume-level encryption will be added in the next version.

[1]
https://lore.kernel.org/linux-btrfs/[email protected]/
[2] https://lore.kernel.org/linux-btrfs/[email protected]
[3] https://lore.kernel.org/linux-btrfs/[email protected]

Changelog:

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]
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 (16):
fscrypt: expose fscrypt_nokey_name
fscrypt: add flag allowing partially-encrypted directories
fscrypt: add fscrypt_have_same_policy() to check inode's compatibility
btrfs: store directorys' encryption state
btrfs: factor a fscrypt_name matching method
btrfs: disable various operations on encrypted inodes
btrfs: add fscrypt operation table to superblock
btrfs: start using fscrypt hooks.
btrfs: add fscrypt_context items.
btrfs: translate btrfs encryption flags and encrypted inode flag.
btrfs: store an IV per encrypted normal file extent
btrfs: Add new FEATURE_INCOMPAT_FSCRYPT feature flag.
btrfs: reuse encrypted filename hash when possible.
btrfs: adapt directory read and lookup to potentially encrypted
filenames
btrfs: encrypt normal file extent data if appropriate
btrfs: implement fscrypt ioctls

Sweet Tea Dorminy (5):
fscrypt: add a function for a filesystem to generate an IV
fscrypt: add new encryption policy for btrfs.
btrfs: use fscrypt_name's instead of name/len everywhere.
btrfs: setup fscrypt_names from dentrys using helper
btrfs: add iv generation function for fscrypt

 fs/btrfs/Makefile               |   1 +
 fs/btrfs/btrfs_inode.h          |   3 +
 fs/btrfs/ctree.h                | 113 +++++--
 fs/btrfs/delayed-inode.c        |  48 ++-
 fs/btrfs/delayed-inode.h        |   9 +-
 fs/btrfs/dir-item.c             | 119 ++++---
 fs/btrfs/extent_io.c            |  93 +++++-
 fs/btrfs/extent_io.h            |   2 +
 fs/btrfs/extent_map.h           |   8 +
 fs/btrfs/file-item.c            |  20 +-
 fs/btrfs/file.c                 |  11 +-
 fs/btrfs/fscrypt.c              | 224 +++++++++++++
 fs/btrfs/fscrypt.h              |  49 +++
 fs/btrfs/inode-item.c           |  84 ++---
 fs/btrfs/inode-item.h           |  14 +-
 fs/btrfs/inode.c                | 573 ++++++++++++++++++++++++--------
 fs/btrfs/ioctl.c                |  80 ++++-
 fs/btrfs/ordered-data.c         |  13 +-
 fs/btrfs/ordered-data.h         |   3 +-
 fs/btrfs/print-tree.c           |   4 +-
 fs/btrfs/props.c                |  11 +-
 fs/btrfs/reflink.c              |   8 +
 fs/btrfs/root-tree.c            |  20 +-
 fs/btrfs/send.c                 | 141 +++++---
 fs/btrfs/super.c                |   8 +-
 fs/btrfs/transaction.c          |  43 ++-
 fs/btrfs/tree-checker.c         |  56 +++-
 fs/btrfs/tree-log.c             | 233 +++++++------
 fs/btrfs/tree-log.h             |   4 +-
 fs/btrfs/xattr.c                |  21 +-
 fs/crypto/crypto.c              |  40 ++-
 fs/crypto/fname.c               |  56 +---
 fs/crypto/fscrypt_private.h     |   4 +-
 fs/crypto/inline_crypt.c        |  20 +-
 fs/crypto/keysetup.c            |   5 +
 fs/crypto/policy.c              |  48 ++-
 include/linux/fscrypt.h         |  62 +++-
 include/uapi/linux/btrfs.h      |   1 +
 include/uapi/linux/btrfs_tree.h |  26 ++
 include/uapi/linux/fscrypt.h    |   1 +
 40 files changed, 1719 insertions(+), 560 deletions(-)
 create mode 100644 fs/btrfs/fscrypt.c
 create mode 100644 fs/btrfs/fscrypt.h
Signature · 1 line
2.35.1