linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] fscrypt: d_revalidate fixes and cleanups
@ 2019-03-20 18:39 Eric Biggers
  2019-03-20 18:39 ` [PATCH v2 1/5] fscrypt: clean up and improve dentry revalidation Eric Biggers
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Eric Biggers @ 2019-03-20 18:39 UTC (permalink / raw)
  To: linux-fscrypt
  Cc: linux-fsdevel, linux-ext4, linux-f2fs-devel, linux-mtd,
	linux-unionfs, Sarthak Kukreti, Gao Xiang

From: Eric Biggers <ebiggers@google.com>

This patch series improves dentry revalidation in fscrypt.

To recap, fscrypt (aka ext4/f2fs/ubifs encryption) encrypts both file
contents and file names in individual directory trees.  A single
filesystem can contain many encrypted directory trees using many
different encryption keys.  Major users of fscrypt require the ability
to delete encrypted files when their encryption key is unavailable, e.g.
when the system needs to delete a removed user's home directory or free
up space from a logged-out user's cache directory.

Therefore fscrypt allows listing, looking up, and deleting files in
encrypted directories via encoded ciphertext names, but only before the
key is added.  After the key is added, the ciphertext names are
invalidated via ->d_revalidate() and plaintext names are shown instead.

fscrypt isn't a stacked filesystem, and it's explicitly for storage
encryption, not OS-level access control.  Thus, whether each directory
inode has its key or not is a global state, not per-process.  Also, the
inode keeps its key until it's evicted from the inode cache.  So,
plaintext names shouldn't ever get invalidated by ->d_revalidate().

This patch series makes the following improvements:

- Only assign ->d_revalidate() to ciphertext filenames, thus allowing
  overlayfs to use an fscrypt-encrypted upperdir in some cases.
  (Previous discussion: https://lkml.org/lkml/2019/3/13/255)

- Fix cases where plaintext filenames would wrongly be invalidated,
  including a real-world bug recently reported on Chromium OS.

- Fix cases where ciphertext filenames would wrongly not be invalidated.

- Allow rcu-walk lookups in encrypted directories with the key, which
  improves performance.
  (Previous attempt: https://patchwork.kernel.org/patch/10594133/)

- Fix cases where rename() and link() could succeed on ciphertext names.

Changed since v1:

- Fixed comment in fscrypt_d_revalidate() to explain that dget_parent()
  is actually still required.

- Moved clearing DCACHE_ENCRYPTED_NAME into fscrypt.h, to avoid an extra
  #ifdef and cluttering up dcache.c.

Eric Biggers (5):
  fscrypt: clean up and improve dentry revalidation
  fscrypt: fix race allowing rename() and link() of ciphertext dentries
  fs, fscrypt: clear DCACHE_ENCRYPTED_NAME when unaliasing directory
  fscrypt: only set dentry_operations on ciphertext dentries
  fscrypt: fix race where ->lookup() marks plaintext dentry as
    ciphertext

 fs/crypto/crypto.c      | 58 ++++++++++++++++---------------
 fs/crypto/fname.c       |  1 +
 fs/crypto/hooks.c       | 28 ++++++++++-----
 fs/dcache.c             |  2 ++
 fs/ext4/ext4.h          | 62 +++++++++++++++++++++++++--------
 fs/ext4/namei.c         | 76 ++++++++++++++++++++++++++++-------------
 fs/f2fs/namei.c         | 17 +++++----
 fs/ubifs/dir.c          |  8 ++---
 include/linux/dcache.h  |  2 +-
 include/linux/fscrypt.h | 61 +++++++++++++++++++++++----------
 10 files changed, 208 insertions(+), 107 deletions(-)

-- 
2.21.0.225.g810b269d1ac-goog


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

end of thread, other threads:[~2019-04-17 14:25 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 18:39 [PATCH v2 0/5] fscrypt: d_revalidate fixes and cleanups Eric Biggers
2019-03-20 18:39 ` [PATCH v2 1/5] fscrypt: clean up and improve dentry revalidation Eric Biggers
2019-04-16 23:08   ` Theodore Ts'o
2019-04-17  0:10     ` Eric Biggers
2019-04-17 13:50       ` Theodore Ts'o
2019-03-20 18:39 ` [PATCH v2 2/5] fscrypt: fix race allowing rename() and link() of ciphertext dentries Eric Biggers
2019-04-17 13:53   ` Theodore Ts'o
2019-03-20 18:39 ` [PATCH v2 3/5] fs, fscrypt: clear DCACHE_ENCRYPTED_NAME when unaliasing directory Eric Biggers
2019-04-17 14:06   ` Theodore Ts'o
2019-03-20 18:39 ` [PATCH v2 4/5] fscrypt: only set dentry_operations on ciphertext dentries Eric Biggers
2019-04-17 14:07   ` Theodore Ts'o
2019-03-20 18:39 ` [PATCH v2 5/5] fscrypt: fix race where ->lookup() marks plaintext dentry as ciphertext Eric Biggers
2019-04-17 14:24   ` Theodore Ts'o
2019-04-01 17:11 ` [PATCH v2 0/5] fscrypt: d_revalidate fixes and cleanups Eric Biggers
2019-04-08  8:22   ` Richard Weinberger

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).