@@ -2718,6 +2718,20 @@ static void copy_name(struct dentry *dentry, struct dentry *target)
kfree_rcu(old_name, u.head);
}
+static void fscrypt_update_flags(struct dentry *dentry)
+{
+#ifdef CONFIG_FS_ENCRYPTION
+ /*
+ * When d_splice_alias() moves a directory's encrypted alias to its
+ * decrypted alias as a result of the encryption key being added,
+ * DCACHE_ENCRYPTED_NAME must be cleared. Note that we don't have to
+ * support arbitrary moves of this flag because fscrypt doesn't allow
+ * encrypted aliases to be the source or target of a rename().
+ */
+ dentry->d_flags &= ~DCACHE_ENCRYPTED_NAME;
+#endif
+}
+
/*
* __d_move - move a dentry
* @dentry: entry to move
@@ -2795,6 +2809,7 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
list_move(&dentry->d_child, &dentry->d_parent->d_subdirs);
__d_rehash(dentry);
fsnotify_update_flags(dentry);
+ fscrypt_update_flags(dentry);
write_seqcount_end(&target->d_seq);
write_seqcount_end(&dentry->d_seq);