add patch fix-ocfs2-corrupt-when-updating-journal-superblock-fails
[ext4-patch-queue.git] / enforce-policy-checks-on-cross-rename
blob381ccc74b7d462187f4e371f1915c84010676c23
1 ext4 crypto: enforce crypto policy restrictions on cross-renames
3 Thanks to Chao Yu <chao2.yu@samsung.com> for pointing out the need for
4 this check.
6 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 ---
8  fs/ext4/namei.c | 9 +++++++++
9  1 file changed, 9 insertions(+)
11 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
12 index 8888977..24fc7a5 100644
13 --- a/fs/ext4/namei.c
14 +++ b/fs/ext4/namei.c
15 @@ -3653,6 +3653,15 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
16         u8 new_file_type;
17         int retval;
19 +       if ((ext4_encrypted_inode(old_dir) ||
20 +            ext4_encrypted_inode(new_dir)) &&
21 +           (old_dir != new_dir) &&
22 +           (!ext4_is_child_context_consistent_with_parent(new_dir,
23 +                                                          old.inode) ||
24 +            !ext4_is_child_context_consistent_with_parent(old_dir,
25 +                                                          new.inode)))
26 +               return -EPERM;
28         dquot_initialize(old.dir);
29         dquot_initialize(new.dir);