Skip to content

Commit 501e43f

Browse files
committed
fscrypt: rename DCACHE_ENCRYPTED_NAME to DCACHE_NOKEY_NAME
Originally we used the term "encrypted name" or "ciphertext name" to mean the encoded filename that is shown when an encrypted directory is listed without its key. But these terms are ambiguous since they also mean the filename stored on-disk. "Encrypted name" is especially ambiguous since it could also be understood to mean "this filename is encrypted on-disk", similar to "encrypted file". So we've started calling these encoded names "no-key names" instead. Therefore, rename DCACHE_ENCRYPTED_NAME to DCACHE_NOKEY_NAME to avoid confusion about what this flag means. Link: https://lore.kernel.org/r/20200924042624.98439-3-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com>
1 parent 70fb261 commit 501e43f

4 files changed

Lines changed: 11 additions & 12 deletions

File tree

‎fs/crypto/fname.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags)
541541
* reverting to no-key names without evicting the directory's inode
542542
* -- which implies eviction of the dentries in the directory.
543543
*/
544-
if (!(dentry->d_flags & DCACHE_ENCRYPTED_NAME))
544+
if (!(dentry->d_flags & DCACHE_NOKEY_NAME))
545545
return 1;
546546

547547
/*

‎fs/crypto/hooks.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int __fscrypt_prepare_link(struct inode *inode, struct inode *dir,
6161
return err;
6262

6363
/* ... in case we looked up no-key name before key was added */
64-
if (dentry->d_flags & DCACHE_ENCRYPTED_NAME)
64+
if (dentry->d_flags & DCACHE_NOKEY_NAME)
6565
return -ENOKEY;
6666

6767
if (!fscrypt_has_permitted_context(dir, inode))
@@ -86,8 +86,7 @@ int __fscrypt_prepare_rename(struct inode *old_dir, struct dentry *old_dentry,
8686
return err;
8787

8888
/* ... in case we looked up no-key name(s) before key was added */
89-
if ((old_dentry->d_flags | new_dentry->d_flags) &
90-
DCACHE_ENCRYPTED_NAME)
89+
if ((old_dentry->d_flags | new_dentry->d_flags) & DCACHE_NOKEY_NAME)
9190
return -ENOKEY;
9291

9392
if (old_dir != new_dir) {
@@ -116,7 +115,7 @@ int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry,
116115

117116
if (fname->is_nokey_name) {
118117
spin_lock(&dentry->d_lock);
119-
dentry->d_flags |= DCACHE_ENCRYPTED_NAME;
118+
dentry->d_flags |= DCACHE_NOKEY_NAME;
120119
spin_unlock(&dentry->d_lock);
121120
d_set_d_op(dentry, &fscrypt_d_ops);
122121
}

‎include/linux/dcache.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ struct dentry_operations {
213213

214214
#define DCACHE_MAY_FREE 0x00800000
215215
#define DCACHE_FALLTHRU 0x01000000 /* Fall through to lower layer */
216-
#define DCACHE_ENCRYPTED_NAME 0x02000000 /* Encrypted name (dir key was unavailable) */
216+
#define DCACHE_NOKEY_NAME 0x02000000 /* Encrypted name encoded without key */
217217
#define DCACHE_OP_REAL 0x04000000
218218

219219
#define DCACHE_PAR_LOOKUP 0x10000000 /* being looked up (with parent locked shared) */

‎include/linux/fscrypt.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ static inline bool fscrypt_needs_contents_encryption(const struct inode *inode)
100100
}
101101

102102
/*
103-
* When d_splice_alias() moves a directory's encrypted alias to its decrypted
104-
* alias as a result of the encryption key being added, DCACHE_ENCRYPTED_NAME
105-
* must be cleared. Note that we don't have to support arbitrary moves of this
106-
* flag because fscrypt doesn't allow encrypted aliases to be the source or
107-
* target of a rename().
103+
* When d_splice_alias() moves a directory's no-key alias to its plaintext alias
104+
* as a result of the encryption key being added, DCACHE_NOKEY_NAME must be
105+
* cleared. Note that we don't have to support arbitrary moves of this flag
106+
* because fscrypt doesn't allow no-key names to be the source or target of a
107+
* rename().
108108
*/
109109
static inline void fscrypt_handle_d_move(struct dentry *dentry)
110110
{
111-
dentry->d_flags &= ~DCACHE_ENCRYPTED_NAME;
111+
dentry->d_flags &= ~DCACHE_NOKEY_NAME;
112112
}
113113

114114
/* crypto.c */

0 commit comments

Comments
 (0)