aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ecryptfs/inode.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 5726d7adaf5b..764dc777b268 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -614,6 +614,7 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
614 struct dentry *lower_new_dentry; 614 struct dentry *lower_new_dentry;
615 struct dentry *lower_old_dir_dentry; 615 struct dentry *lower_old_dir_dentry;
616 struct dentry *lower_new_dir_dentry; 616 struct dentry *lower_new_dir_dentry;
617 struct dentry *trap = NULL;
617 618
618 lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry); 619 lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry);
619 lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry); 620 lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry);
@@ -621,7 +622,17 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
621 dget(lower_new_dentry); 622 dget(lower_new_dentry);
622 lower_old_dir_dentry = dget_parent(lower_old_dentry); 623 lower_old_dir_dentry = dget_parent(lower_old_dentry);
623 lower_new_dir_dentry = dget_parent(lower_new_dentry); 624 lower_new_dir_dentry = dget_parent(lower_new_dentry);
624 lock_rename(lower_old_dir_dentry, lower_new_dir_dentry); 625 trap = lock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
626 /* source should not be ancestor of target */
627 if (trap == lower_old_dentry) {
628 rc = -EINVAL;
629 goto out_lock;
630 }
631 /* target should not be ancestor of source */
632 if (trap == lower_new_dentry) {
633 rc = -ENOTEMPTY;
634 goto out_lock;
635 }
625 rc = vfs_rename(lower_old_dir_dentry->d_inode, lower_old_dentry, 636 rc = vfs_rename(lower_old_dir_dentry->d_inode, lower_old_dentry,
626 lower_new_dir_dentry->d_inode, lower_new_dentry); 637 lower_new_dir_dentry->d_inode, lower_new_dentry);
627 if (rc) 638 if (rc)