|
Kmods SIG |
1bd144 |
From 74dd7c97ea2ab08b41925ab2f472db573accda89 Mon Sep 17 00:00:00 2001
|
|
Kmods SIG |
1bd144 |
From: Al Viro <viro@zeniv.linux.org.uk>
|
|
Kmods SIG |
1bd144 |
Date: Tue, 9 Oct 2018 23:32:41 -0400
|
|
Kmods SIG |
1bd144 |
Subject: [Backport 74dd7c97ea2a] ecryptfs_rename(): verify that lower dentries
|
|
Kmods SIG |
1bd144 |
are still OK after lock_rename()
|
|
Kmods SIG |
1bd144 |
|
|
Kmods SIG |
1bd144 |
We get lower layer dentries, find their parents, do lock_rename() and
|
|
Kmods SIG |
1bd144 |
proceed to vfs_rename(). However, we do not check that dentries still
|
|
Kmods SIG |
1bd144 |
have the same parents and are not unlinked. Need to check that...
|
|
Kmods SIG |
1bd144 |
|
|
Kmods SIG |
1bd144 |
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
Kmods SIG |
1bd144 |
---
|
|
Kmods SIG |
1bd144 |
src/inode.c | 11 ++++++++---
|
|
Kmods SIG |
1bd144 |
1 file changed, 8 insertions(+), 3 deletions(-)
|
|
Kmods SIG |
1bd144 |
|
|
Kmods SIG |
1bd144 |
diff --git a/src/inode.c b/src/inode.c
|
|
Kmods SIG |
1bd144 |
index 49121e5a8de228acfb1ea126250e5ad94e4ec812..5c36ceecb5c12828ceb84a39d19c86b69713b937 100644
|
|
Kmods SIG |
1bd144 |
--- a/src/inode.c
|
|
Kmods SIG |
1bd144 |
+++ b/src/inode.c
|
|
Kmods SIG |
1bd144 |
@@ -593,11 +593,16 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|
Kmods SIG |
1bd144 |
lower_new_dir_dentry = dget_parent(lower_new_dentry);
|
|
Kmods SIG |
1bd144 |
target_inode = d_inode(new_dentry);
|
|
Kmods SIG |
1bd144 |
trap = lock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
|
|
Kmods SIG |
1bd144 |
+ rc = -EINVAL;
|
|
Kmods SIG |
1bd144 |
+ if (lower_old_dentry->d_parent != lower_old_dir_dentry)
|
|
Kmods SIG |
1bd144 |
+ goto out_lock;
|
|
Kmods SIG |
1bd144 |
+ if (lower_new_dentry->d_parent != lower_new_dir_dentry)
|
|
Kmods SIG |
1bd144 |
+ goto out_lock;
|
|
Kmods SIG |
1bd144 |
+ if (d_unhashed(lower_old_dentry) || d_unhashed(lower_new_dentry))
|
|
Kmods SIG |
1bd144 |
+ goto out_lock;
|
|
Kmods SIG |
1bd144 |
/* source should not be ancestor of target */
|
|
Kmods SIG |
1bd144 |
- if (trap == lower_old_dentry) {
|
|
Kmods SIG |
1bd144 |
- rc = -EINVAL;
|
|
Kmods SIG |
1bd144 |
+ if (trap == lower_old_dentry)
|
|
Kmods SIG |
1bd144 |
goto out_lock;
|
|
Kmods SIG |
1bd144 |
- }
|
|
Kmods SIG |
1bd144 |
/* target should not be ancestor of source */
|
|
Kmods SIG |
1bd144 |
if (trap == lower_new_dentry) {
|
|
Kmods SIG |
1bd144 |
rc = -ENOTEMPTY;
|
|
Kmods SIG |
1bd144 |
--
|
|
Kmods SIG |
1bd144 |
2.31.1
|
|
Kmods SIG |
1bd144 |
|