Make __d_move() clear DCACHE_ENCRYPTED_NAME on the source dentry. This is needed for when d_splice_alias() moves a directory's encrypted alias to its decrypted alias as a result of the encryption key being added. Otherwise, the decrypted alias will incorrectly be invalidated on the next lookup, causing problems such as unmounting a mount the user just mount()ed there. Note that we don't have to support arbitrary moves of this flag because fscrypt doesn't allow dentries with DCACHE_ENCRYPTED_NAME to be the source or target of a rename().
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -89,6 +89,18 @@ static inline bool fscrypt_dummy_context_enabled(struct inode *inode) · 88 unmodified lines | |||
| 89 | inode->i_sb->s_cop->dummy_context(inode); | 89 | inode->i_sb->s_cop->dummy_context(inode); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | /* | ||
| 93 | * When d_splice_alias() moves a directory's encrypted alias to its decrypted | ||
| 94 | * alias as a result of the encryption key being added, DCACHE_ENCRYPTED_NAME | ||
| 95 | * must be cleared. Note that we don't have to support arbitrary moves of this | ||
| 96 | * flag because fscrypt doesn't allow encrypted aliases to be the source or | ||
| 97 | * target of a rename(). | ||
| 98 | */ | ||
| 99 | static inline void fscrypt_handle_d_move(struct dentry *dentry) | ||
| 100 | { | ||
| 101 | dentry->d_flags &= ~DCACHE_ENCRYPTED_NAME; | ||
| 102 | } | ||
| 103 | |||
| 92 | /* crypto.c */ | 104 | /* crypto.c */ |
| 93 | extern void fscrypt_enqueue_decrypt_work(struct work_struct *); | 105 | extern void fscrypt_enqueue_decrypt_work(struct work_struct *); |
| 94 | extern struct fscrypt_ctx *fscrypt_get_ctx(gfp_t); | 106 | extern struct fscrypt_ctx *fscrypt_get_ctx(gfp_t); |
| @@ -244,6 +256,10 @@ static inline bool fscrypt_dummy_context_enabled(struct inode *inode) · 149 unmodified lines | |||
| 244 | return false; | 256 | return false; |
| 245 | } | 257 | } |
| 246 | 258 | ||
| 259 | static inline void fscrypt_handle_d_move(struct dentry *dentry) | ||
| 260 | { | ||
| 261 | } | ||
| 262 | |||
| 247 | /* crypto.c */ | 263 | /* crypto.c */ |
| 248 | static inline void fscrypt_enqueue_decrypt_work(struct work_struct *work) | 264 | static inline void fscrypt_enqueue_decrypt_work(struct work_struct *work) |
| 249 | { | 265 | { |