aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/fs/crypto/hooks.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-03-20 11:39:09 -0700
committerTheodore Ts'o <tytso@mit.edu>2019-04-17 09:48:46 -0400
commit6cc248684d3d23bbd073ae2fa73d3416c0558909 (patch)
tree1fe0b6a608ccdae37511795fd20857e45435622d /fs/crypto/hooks.c
parentfscrypt: use READ_ONCE() to access ->i_crypt_info (diff)
downloadwireguard-linux-6cc248684d3d23bbd073ae2fa73d3416c0558909.tar.xz
wireguard-linux-6cc248684d3d23bbd073ae2fa73d3416c0558909.zip
fscrypt: clean up and improve dentry revalidation
Make various improvements to fscrypt dentry revalidation: - Don't try to handle the case where the per-directory key is removed, as this can't happen without the inode (and dentries) being evicted. - Flag ciphertext dentries rather than plaintext dentries, since it's ciphertext dentries that need the special handling. - Avoid doing unnecessary work for non-ciphertext dentries. - When revalidating ciphertext dentries, try to set up the directory's i_crypt_info to make sure the key is really still absent, rather than invalidating all negative dentries as the previous code did. An old comment suggested we can't do this for locking reasons, but AFAICT this comment was outdated and it actually works fine. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/crypto/hooks.c')
-rw-r--r--fs/crypto/hooks.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/crypto/hooks.c b/fs/crypto/hooks.c
index 56debb1fcf5e..a9492f75bbe1 100644
--- a/fs/crypto/hooks.c
+++ b/fs/crypto/hooks.c
@@ -101,9 +101,9 @@ int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry)
if (err)
return err;
- if (fscrypt_has_encryption_key(dir)) {
+ if (!fscrypt_has_encryption_key(dir)) {
spin_lock(&dentry->d_lock);
- dentry->d_flags |= DCACHE_ENCRYPTED_WITH_KEY;
+ dentry->d_flags |= DCACHE_ENCRYPTED_NAME;
spin_unlock(&dentry->d_lock);
}