aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@google.com>2015-05-28 21:39:33 -0400
committerMister Oyster <oysterized@gmail.com>2017-05-27 19:40:04 +0200
commit3d55c56fe820327be245d1237d10cc2730488101 (patch)
treebca1493b540e5220bb51ddcd7b99e31bbe6b3142
parent944848ad3bb678cfc6cfd9ee41ebe8a1c6f00082 (diff)
ext4 crypto: enforce crypto policy restrictions on cross-renames
Thanks to Chao Yu <chao2.yu@samsung.com> for pointing out the need for this check. Change-Id: I957a4e4be043582972d3c8799f18826fc136d567 Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Theodore Ts'o <tytso@google.com>
-rw-r--r--fs/ext4/namei.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 8608118d2..f557def0e 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3652,6 +3652,15 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
u8 new_file_type;
int retval;
+ if ((ext4_encrypted_inode(old_dir) ||
+ ext4_encrypted_inode(new_dir)) &&
+ (old_dir != new_dir) &&
+ (!ext4_is_child_context_consistent_with_parent(new_dir,
+ old.inode) ||
+ !ext4_is_child_context_consistent_with_parent(old_dir,
+ new.inode)))
+ return -EPERM;
+
dquot_initialize(old.dir);
dquot_initialize(new.dir);