summaryrefslogtreecommitdiff
path: root/fs/f2fs/namei.c
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2015-05-25 13:07:02 +0300
committerJaegeuk Kim <jaegeuk@kernel.org>2015-06-02 02:21:05 +0300
commitd3baf7c4725601d4689397b9f7dde9e3ddea032d (patch)
tree5ad0bae1f48ef76cdcdcdc4cb04b707610d9c26c /fs/f2fs/namei.c
parent12377024719f08b7411afe9fc0169b13808dfefa (diff)
downloadlinux-d3baf7c4725601d4689397b9f7dde9e3ddea032d.tar.xz
f2fs crypto: check context consistent for rename2
For exchange rename, we should check context consistent of encryption between new_dir and old_inode or old_dir and new_inode. Otherwise inheritance of parent's encryption context will be broken. Signed-off-by: Chao Yu <chao2.yu@samsung.com> [Jaegeuk Kim: sync with ext4 approach] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/namei.c')
-rw-r--r--fs/f2fs/namei.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 55d0d27dfdf2..1cc24a0cbc58 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -756,6 +756,14 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
int old_nlink = 0, new_nlink = 0;
int err = -ENOENT;
+ if ((f2fs_encrypted_inode(old_dir) || f2fs_encrypted_inode(new_dir)) &&
+ (old_dir != new_dir) &&
+ (!f2fs_is_child_context_consistent_with_parent(new_dir,
+ old_inode) ||
+ !f2fs_is_child_context_consistent_with_parent(old_dir,
+ new_inode)))
+ return -EPERM;
+
f2fs_balance_fs(sbi);
old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page);