Skip to content

btrfs: add fscrypt support

Josef Bacik linux-btrfs linux-fscrypt oe-kbuild oe-kbuild-all 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest35 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/35fscrypt: rename fscrypt_info => fscrypt_inode_infofs/crypto/crypto.c fs/crypto/fname.c fs/crypto/fscrypt_private.h +8 more+82 -710 replies
2/35fscrypt: add per-extent encryption supportfs/crypto/crypto.c fs/crypto/fscrypt_private.h fs/crypto/inline_crypt.c +3 more+403 -10 replies
3/35fscrypt: disable all but standard v2 policies for extent encryptionfs/crypto/policy.c+12 -00 replies
4/35blk-crypto: add a process bio callbackblock/blk-crypto-fallback.c block/blk-crypto-profile.c block/blk-crypto.c +4 more+65 -40 replies
5/35fscrypt: expose fscrypt_nokey_namefs/crypto/fname.c include/linux/fscrypt.h+38 -380 replies
6/35fscrypt: add documentation about extent encryptionDocumentation/filesystems/fscrypt.rst+36 -00 replies
7/35btrfs: add infrastructure for safe em freeingfs/btrfs/extent_map.c fs/btrfs/extent_map.h fs/btrfs/tree-log.c+89 -70 replies
8/35btrfs: disable various operations on encrypted inodesfs/btrfs/inode.c fs/btrfs/reflink.c+9 -10 replies
9/35btrfs: disable verity on encrypted inodesfs/btrfs/verity.c+3 -00 replies
10/35btrfs: start using fscrypt hooksfs/btrfs/Makefile fs/btrfs/btrfs_inode.h fs/btrfs/file.c +4 more+117 -180 replies
11/35btrfs: add inode encryption contextsfs/btrfs/fscrypt.c fs/btrfs/fscrypt.h fs/btrfs/inode.c +2 more+154 -20 replies
12/35btrfs: add new FEATURE_INCOMPAT_ENCRYPT flagfs/btrfs/fs.h fs/btrfs/super.c fs/btrfs/sysfs.c +1 more+14 -10 replies
13/35btrfs: adapt readdir for encrypted and nokey namesfs/btrfs/btrfs_inode.h fs/btrfs/delayed-inode.c fs/btrfs/delayed-inode.h +10 more+297 -730 replies
14/35btrfs: handle nokey names.fs/btrfs/dir-item.c fs/btrfs/fscrypt.c fs/btrfs/fscrypt.h+73 -20 replies
15/35btrfs: implement fscrypt ioctlsfs/btrfs/ioctl.c+28 -00 replies
16/35btrfs: add encryption to CONFIG_BTRFS_DEBUGfs/btrfs/ioctl.c+2 -00 replies
17/35btrfs: add get_devices hook for fscryptfs/btrfs/fscrypt.c+37 -00 replies
18/35btrfs: turn on inlinecrypt mount option for encryptfs/btrfs/ioctl.c fs/btrfs/super.c+13 -00 replies
19/35btrfs: set file extent encryption excplicitlyfs/btrfs/accessors.h fs/btrfs/inode.c fs/btrfs/tree-checker.c +2 more+22 -60 replies
20/35btrfs: add fscrypt_info and encryption_type to extent_mapfs/btrfs/extent_map.c fs/btrfs/extent_map.h fs/btrfs/file-item.c +1 more+33 -30 replies
21/35btrfs: add fscrypt_info and encryption_type to ordered_extentfs/btrfs/ordered-data.c fs/btrfs/ordered-data.h+8 -00 replies
22/35btrfs: plumb through setting the fscrypt_info for ordered extentsfs/btrfs/inode.c fs/btrfs/ordered-data.c fs/btrfs/ordered-data.h+36 -250 replies
23/35btrfs: populate the ordered_extent with the fscrypt contextfs/btrfs/inode.c+43 -190 replies
24/35btrfs: keep track of fscrypt info and orig_start for dio readsfs/btrfs/inode.c+11 -00 replies
25/35btrfs: add an optional encryption context to the end of file extentsfs/btrfs/accessors.h fs/btrfs/tree-checker.c include/uapi/linux/btrfs_tree.h+113 -100 replies
26/35btrfs: explicitly track file extent length for replace and dropfs/btrfs/ctree.h fs/btrfs/file.c fs/btrfs/inode.c +2 more+13 -60 replies
27/35btrfs: pass through fscrypt_extent_info to the file extent helpersfs/btrfs/inode.c fs/btrfs/tree-log.c+12 -80 replies
28/35btrfs: pass the fscrypt_info through the replace extent infrastructurefs/btrfs/ctree.h fs/btrfs/inode.c+3 -00 replies
29/35btrfs: implement the fscrypt extent encryption hooksfs/btrfs/defrag.c fs/btrfs/file-item.c fs/btrfs/file-item.h +5 more+142 -40 replies
30/35btrfs: setup fscrypt_extent_info for new extentsfs/btrfs/inode.c+37 -20 replies
31/35btrfs: populate ordered_extent with the orig offsetfs/btrfs/inode.c fs/btrfs/ordered-data.c fs/btrfs/ordered-data.h+31 -180 replies
32/35btrfs: set the bio fscrypt context when applicablefs/btrfs/compression.c fs/btrfs/extent_io.c fs/btrfs/fscrypt.c +2 more+136 -10 replies
33/35btrfs: add a bio argument to btrfs_csum_one_biofs/btrfs/bio.c fs/btrfs/file-item.c fs/btrfs/file-item.h+3 -40 replies
34/35btrfs: add orig_logical to btrfs_biofs/btrfs/bio.c fs/btrfs/bio.h fs/btrfs/file-item.c+13 -10 replies
35/35btrfs: implement process_bio cb for fscryptfs/btrfs/bio.c fs/btrfs/bio.h fs/btrfs/fscrypt.c+55 -10 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/35] btrfs: add fscrypt support

Hello,

This is the newly reworked fscrypt support for btrfs. There have been a few things changed since Sweet Tea's last post[1], and my RFC[2]. The changes from Sweet Tea's patchset are mostly related to the fscrypt changes, but I'll detail them here

- We have a fscrypt_extent_info struct that simply has the blk key in it and a nonce.
- We have a stripped down on disk context that just has what we need for extents. At this time we only care about the nonce, everything else is supposed to match the owning inode.
- I've disabled everything except bog standard v2 policies to limit the complexity.
- Added the necessary hooks we needed for checksumming the encrypted bios.
- Reworked the on-disk stuff to be better described and accessed through helpers.
- Plumbed through the fscrypt_extent_info through everything to simplify the API calls we need from fscrypt.
- Instead of handling async key free'ing in fscrypt, handle the case where we're freeing extent_maps under the lock in a safe way. This is cleaner than pushing this into fscrypt.
- Fixed a few things that fsstress uncovered in testing.

Changes to the fscrypt code since my RFC

- Took Eric's advice and added the policy and key to the extent context, this way if we want to in the future we could handle key changing.
- Added a helper to give us the fscrypt extent info context size. We need the size ahead of time to setup the item properly.
- Fixed the blk crypto fallback not actually working with our process_bio callback. Added a policy flag to make sure the checks work properly.
- Added some documentation.

Things left to do

- I still have to update fstests to deal with v2 only policies. I haven't touched fstests at all yet, I've merely done my own rough testing with fsstress.
- Update the btrfs-progs patches. This needs to be done to get the fstests stuff to work as well.
- fsverity still isn't encrypted. I'm going to hit that next, it should be straightforward enough.

This is based on for-next from Dave's tree [3], but in case that moves between now and then you can see my current branch here [4]. Thanks,

Josef

[1] https://lore.kernel.org/linux-fscrypt/[email protected]/
[2] https://lore.kernel.org/linux-btrfs/[email protected]/
[3] https://github.com/kdave/btrfs-devel/tree/for-next
[4] https://github.com/josefbacik/linux/tree/fscrypt

Josef Bacik (20):
fscrypt: rename fscrypt_info => fscrypt_inode_info
fscrypt: add per-extent encryption support
fscrypt: disable all but standard v2 policies for extent encryption
blk-crypto: add a process bio callback
fscrypt: add documentation about extent encryption
btrfs: add infrastructure for safe em freeing
btrfs: add fscrypt_info and encryption_type to ordered_extent
btrfs: plumb through setting the fscrypt_info for ordered extents
btrfs: populate the ordered_extent with the fscrypt context
btrfs: keep track of fscrypt info and orig_start for dio reads
btrfs: add an optional encryption context to the end of file extents
btrfs: pass through fscrypt_extent_info to the file extent helpers
btrfs: pass the fscrypt_info through the replace extent infrastructure
btrfs: implement the fscrypt extent encryption hooks
btrfs: setup fscrypt_extent_info for new extents
btrfs: populate ordered_extent with the orig offset
btrfs: set the bio fscrypt context when applicable
btrfs: add a bio argument to btrfs_csum_one_bio
btrfs: add orig_logical to btrfs_bio
btrfs: implement process_bio cb for fscrypt

Omar Sandoval (7):
fscrypt: expose fscrypt_nokey_name
btrfs: disable various operations on encrypted inodes
btrfs: start using fscrypt hooks
btrfs: add inode encryption contexts
btrfs: add new FEATURE_INCOMPAT_ENCRYPT flag
btrfs: adapt readdir for encrypted and nokey names
btrfs: implement fscrypt ioctls

Sweet Tea Dorminy (8):
btrfs: disable verity on encrypted inodes
btrfs: handle nokey names.
btrfs: add encryption to CONFIG_BTRFS_DEBUG
btrfs: add get_devices hook for fscrypt
btrfs: turn on inlinecrypt mount option for encrypt
btrfs: set file extent encryption excplicitly
btrfs: add fscrypt_info and encryption_type to extent_map
btrfs: explicitly track file extent length for replace and drop

 Documentation/filesystems/fscrypt.rst |  36 ++
 block/blk-crypto-fallback.c           |  28 ++
 block/blk-crypto-profile.c            |   2 +
 block/blk-crypto.c                    |   6 +-
 fs/btrfs/Makefile                     |   1 +
 fs/btrfs/accessors.h                  |  50 +++
 fs/btrfs/bio.c                        |  45 ++-
 fs/btrfs/bio.h                        |   6 +
 fs/btrfs/btrfs_inode.h                |   3 +-
 fs/btrfs/compression.c                |   6 +
 fs/btrfs/ctree.h                      |   4 +
 fs/btrfs/defrag.c                     |  10 +-
 fs/btrfs/delayed-inode.c              |  29 +-
 fs/btrfs/delayed-inode.h              |   6 +-
 fs/btrfs/dir-item.c                   | 108 +++++-
 fs/btrfs/dir-item.h                   |  11 +-
 fs/btrfs/extent_io.c                  |  81 ++++-
 fs/btrfs/extent_io.h                  |   3 +
 fs/btrfs/extent_map.c                 | 106 +++++-
 fs/btrfs/extent_map.h                 |  12 +
 fs/btrfs/file-item.c                  |  17 +-
 fs/btrfs/file-item.h                  |   7 +-
 fs/btrfs/file.c                       |  16 +-
 fs/btrfs/fs.h                         |   3 +-
 fs/btrfs/fscrypt.c                    | 326 ++++++++++++++++++
 fs/btrfs/fscrypt.h                    |  95 +++++
 fs/btrfs/inode.c                      | 476 ++++++++++++++++++++------
 fs/btrfs/ioctl.c                      |  41 ++-
 fs/btrfs/ordered-data.c               |  26 +-
 fs/btrfs/ordered-data.h               |  21 +-
 fs/btrfs/reflink.c                    |   8 +
 fs/btrfs/root-tree.c                  |   8 +-
 fs/btrfs/root-tree.h                  |   2 +-
 fs/btrfs/super.c                      |  17 +
 fs/btrfs/sysfs.c                      |   6 +
 fs/btrfs/tree-checker.c               |  66 +++-
 fs/btrfs/tree-log.c                   |  26 +-
 fs/btrfs/verity.c                     |   3 +
 fs/crypto/crypto.c                    |  23 +-
 fs/crypto/fname.c                     |  45 +--
 fs/crypto/fscrypt_private.h           |  87 ++++-
 fs/crypto/hooks.c                     |   2 +-
 fs/crypto/inline_crypt.c              | 100 +++++-
 fs/crypto/keyring.c                   |   4 +-
 fs/crypto/keysetup.c                  | 190 +++++++++-
 fs/crypto/keysetup_v1.c               |  14 +-
 fs/crypto/policy.c                    |  70 +++-
 include/linux/blk-crypto-profile.h    |   7 +
 include/linux/blk-crypto.h            |   9 +-
 include/linux/fs.h                    |   4 +-
 include/linux/fscrypt.h               | 123 ++++++-
 include/uapi/linux/btrfs.h            |   1 +
 include/uapi/linux/btrfs_tree.h       |  35 +-
 53 files changed, 2144 insertions(+), 287 deletions(-)
 create mode 100644 fs/btrfs/fscrypt.c
 create mode 100644 fs/btrfs/fscrypt.h
Signature · 1 line
2.41.0