linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/9] Support for Casefolding and Encryption
@ 2020-01-17 21:42 Daniel Rosenberg
  2020-01-17 21:42 ` [PATCH v3 1/9] fscrypt: Add siphash and hash key for policy v2 Daniel Rosenberg
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Daniel Rosenberg @ 2020-01-17 21:42 UTC (permalink / raw)
  To: Theodore Ts'o, linux-ext4, Jaegeuk Kim, Chao Yu,
	linux-f2fs-devel, Eric Biggers, linux-fscrypt, Alexander Viro
  Cc: Andreas Dilger, Jonathan Corbet, linux-doc, linux-kernel,
	linux-fsdevel, Gabriel Krisman Bertazi, kernel-team,
	Daniel Rosenberg

These patches are all on top of fscrypt's developement branch

Ext4 and F2FS currently both support casefolding and encryption, but not at
the same time. These patches aim to rectify that.

Since directory names are stored case preserved, we cannot just take the hash
of the ciphertext. Instead we use the siphash of the casefolded name. With this
we no longer have a direct path from an encrypted name to the hash without the
key. To deal with this, fscrypt now always includes the hash in the name it
presents when the key is not present. There is a pre-existing bug where you can
change parts of the hash and still match the name so long as the disruption to
the hash does not happen to affect lookup on that filesystem. I'm not sure how
to fix that without making ext4 lookups slower in the more common case.

I moved the identical dcache operations for ext4 and f2fs into the VFS, as any
filesystem that uses casefolding will need the same code. This will also allow
further optimizations to that path, although my current changes don't take
advantage of that yet.

For Ext4, this also means that we need to store the hash on disk. We only do so
for encrypted and casefolded directories to avoid on disk format changes.
Previously encryption and casefolding could not live on the same filesystem,
and we're relaxing that requirement. F2fs is a bit more straightforward since
it already stores hashes on disk.

I've updated the related tools with just enough to enable the feature. I still
need to adjust ext4's fsck's, although without access to the keys,
neither fsck will be able to verify the hashes of casefolded and encrypted names.

v3 changes:
fscrypt patch only creates hash key if it will be needed.
Rebased on top of fscrypt branch, reconstified match functions in ext4/f2fs

v2 changes:
fscrypt moved to separate thread to rebase on fscrypt dev branch
addressed feedback, plus some minor fixes


Daniel Rosenberg (9):
  fscrypt: Add siphash and hash key for policy v2
  fscrypt: Don't allow v1 policies with casefolding
  fscrypt: Change format of no-key token
  fscrypt: Only create hash key when needed
  vfs: Fold casefolding into vfs
  f2fs: Handle casefolding with Encryption
  ext4: Use struct super_blocks' casefold data
  ext4: Hande casefolding with encryption
  ext4: Optimize match for casefolded encrypted dirs

 Documentation/filesystems/ext4/directory.rst |  27 ++
 fs/crypto/Kconfig                            |   1 +
 fs/crypto/fname.c                            | 232 ++++++++++---
 fs/crypto/fscrypt_private.h                  |   9 +
 fs/crypto/keysetup.c                         |  35 +-
 fs/crypto/policy.c                           |  53 +++
 fs/dcache.c                                  |  28 ++
 fs/ext4/dir.c                                |  75 +----
 fs/ext4/ext4.h                               |  85 +++--
 fs/ext4/hash.c                               |  26 +-
 fs/ext4/ialloc.c                             |   5 +-
 fs/ext4/inline.c                             |  41 +--
 fs/ext4/namei.c                              | 324 ++++++++++++-------
 fs/ext4/super.c                              |  21 +-
 fs/f2fs/dir.c                                | 112 +++----
 fs/f2fs/f2fs.h                               |  12 +-
 fs/f2fs/hash.c                               |  25 +-
 fs/f2fs/inline.c                             |   9 +-
 fs/f2fs/super.c                              |  17 +-
 fs/f2fs/sysfs.c                              |   8 +-
 fs/inode.c                                   |   3 +-
 fs/namei.c                                   |  41 ++-
 include/linux/fs.h                           |  10 +
 include/linux/fscrypt.h                      |  95 ++----
 include/linux/unicode.h                      |  14 +
 25 files changed, 835 insertions(+), 473 deletions(-)

-- 
2.25.0.341.g760bfbb309-goog


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-01-24  4:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17 21:42 [PATCH v3 0/9] Support for Casefolding and Encryption Daniel Rosenberg
2020-01-17 21:42 ` [PATCH v3 1/9] fscrypt: Add siphash and hash key for policy v2 Daniel Rosenberg
2020-01-17 21:42 ` [PATCH v3 2/9] fscrypt: Don't allow v1 policies with casefolding Daniel Rosenberg
2020-01-17 21:42 ` [PATCH v3 3/9] fscrypt: Change format of no-key token Daniel Rosenberg
2020-01-17 21:42 ` [PATCH v3 4/9] fscrypt: Only create hash key when needed Daniel Rosenberg
2020-01-17 21:42 ` [PATCH v3 5/9] vfs: Fold casefolding into vfs Daniel Rosenberg
2020-01-20  1:35   ` Al Viro
2020-01-24  4:30     ` Daniel Rosenberg
2020-01-17 21:42 ` [PATCH v3 6/9] f2fs: Handle casefolding with Encryption Daniel Rosenberg
2020-01-17 21:42 ` [PATCH v3 7/9] ext4: Use struct super_blocks' casefold data Daniel Rosenberg
2020-01-17 21:42 ` [PATCH v3 8/9] ext4: Hande casefolding with encryption Daniel Rosenberg
2020-01-17 21:42 ` [PATCH v3 9/9] ext4: Optimize match for casefolded encrypted dirs Daniel Rosenberg
2020-01-20  4:52 ` [PATCH v3 0/9] Support for Casefolding and Encryption Eric Biggers
2020-01-20 22:10   ` Eric Biggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).