aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-10-09 23:32:41 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2018-10-09 23:33:17 -0400
commit74dd7c97ea2ab08b41925ab2f472db573accda89 (patch)
tree9a336f634fdc2b6250ab1ef50e529830eac8079f
parentb07581d2d5add23ae163e3fbfb2fa5d36076922f (diff)
ecryptfs_rename(): verify that lower dentries are still OK after lock_rename()
We get lower layer dentries, find their parents, do lock_rename() and proceed to vfs_rename(). However, we do not check that dentries still have the same parents and are not unlinked. Need to check that... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/ecryptfs/inode.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 49121e5a8de2..5c36ceecb5c1 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -593,11 +593,16 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
593 lower_new_dir_dentry = dget_parent(lower_new_dentry); 593 lower_new_dir_dentry = dget_parent(lower_new_dentry);
594 target_inode = d_inode(new_dentry); 594 target_inode = d_inode(new_dentry);
595 trap = lock_rename(lower_old_dir_dentry, lower_new_dir_dentry); 595 trap = lock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
596 rc = -EINVAL;
597 if (lower_old_dentry->d_parent != lower_old_dir_dentry)
598 goto out_lock;
599 if (lower_new_dentry->d_parent != lower_new_dir_dentry)
600 goto out_lock;
601 if (d_unhashed(lower_old_dentry) || d_unhashed(lower_new_dentry))
602 goto out_lock;
596 /* source should not be ancestor of target */ 603 /* source should not be ancestor of target */
597 if (trap == lower_old_dentry) { 604 if (trap == lower_old_dentry)
598 rc = -EINVAL;
599 goto out_lock; 605 goto out_lock;
600 }
601 /* target should not be ancestor of source */ 606 /* target should not be ancestor of source */
602 if (trap == lower_new_dentry) { 607 if (trap == lower_new_dentry) {
603 rc = -ENOTEMPTY; 608 rc = -ENOTEMPTY;