f2fs crypto: check context consistent for rename2
PATCH 1/3 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.
--- fs/f2fs/namei.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/f2fs/namei.c +9 -0
@@ -754,6 +754,15 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,int old_nlink =0 , new_nlink =0 ;int err = -ENOENT ; +if ((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))) { + err = -EPERM ; + goto out; + } +f2fs_balance_fs (sbi); old_entry =f2fs_find_entry (old_dir, &old_dentry->d_name, &old_page);
Signature · 1 line
2.3.0
Jaegeuk Kim
maintainerHi Chao,
Quoted 16 lines · Chao Yu
For exchange rename, we should check context consistent of encryption between
new_dirandold_inodeorold_dirandnew_inode. Otherwise inheritance of parent's encryption context will be broken.Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/namei.c | 9 +++++++++ 1 file changed, 9 insertions(+)fs/f2fs/namei.c +0
-0@@ -754,6 +754,15 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,int old_nlink =0 , new_nlink =0 ;int err = -ENOENT ;
fs/f2fs/namei.c static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, · line 765
Quoted 10 lines
fs/f2fs/namei.c +9
-0+if ((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))) { + err = -EPERM ; + goto out; + } +
Seems like we need this?
--- fs/f2fs/namei.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/f2fs/namei.c +15 -0
@@ -756,6 +756,21 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,int old_nlink =0 , new_nlink =0 ;int err = -ENOENT ; +if (old_dir != new_dir) { +if (f2fs_encrypted_inode (new_dir) && + !f2fs_is_child_context_consistent_with_parent (new_dir, + old_inode)) { + err = -EPERM ; + goto out; + } +if (f2fs_encrypted_inode (old_dir) && + !f2fs_is_child_context_consistent_with_parent (old_dir, + new_inode)) { + err = -EPERM ; + goto out; + } + } +f2fs_balance_fs (sbi); old_entry =f2fs_find_entry (old_dir, &old_dentry->d_name, &old_page);
Signature · 1 line
2.1.1
Jaegeuk Kim
maintainerQuoted 48 lines · Jaegeuk Kim
Hi Chao,
Quoted 16 lines · Chao Yu
For exchange rename, we should check context consistent of encryption between
new_dirandold_inodeorold_dirandnew_inode. Otherwise inheritance of parent's encryption context will be broken.Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/namei.c | 9 +++++++++ 1 file changed, 9 insertions(+)fs/f2fs/namei.c +0
-0@@ -754,6 +754,15 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,int old_nlink =0 , new_nlink =0 ;int err = -ENOENT ;fs/f2fs/namei.c static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, · line 765
Quoted 10 lines
fs/f2fs/namei.c +9
-0+if ((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))) { + err = -EPERM ; + goto out; + } +Seems like we need this?
--- fs/f2fs/namei.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)fs/f2fs/namei.c +4
-0@@ -756,6 +756,21 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,int old_nlink =0 , new_nlink =0 ;int err = -ENOENT ; +if (old_dir != new_dir) { +if (f2fs_encrypted_inode (new_dir) && + !f2fs_is_child_context_consistent_with_parent (new_dir, + old_inode)) {
fs/f2fs/namei.c static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, · line 772
Quoted 10 lines
fs/f2fs/namei.c +10
-0+ err = -EPERM ; + goto out; + } +if (f2fs_encrypted_inode (old_dir) && + !f2fs_is_child_context_consistent_with_parent (old_dir, + new_inode)) { + err = -EPERM ; + goto out; + } + }
It needs to sync with ext4 patch published by Ted.
Thanks,
Quoted 13 lines
fs/f2fs/namei.c +1
-0+f2fs_balance_fs (sbi); old_entry =f2fs_find_entry (old_dir, &old_dentry->d_name, &old_page);Signature · 8 lines
2.1.1 ------------------------------------------------------------------------------ _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Hi Jaegeuk,
Quoted 54 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Friday, May 29, 2015 10:29 AM
To: Chao Yu
Cc: [email protected]; [email protected]
Subject: Re: [f2fs-dev] [PATCH 1/3] f2fs crypto: check context consistent for rename2Quoted 12 lines · Jaegeuk Kim
Hi Chao,
Quoted 9 lines · Chao Yu
For exchange rename, we should check context consistent of encryption between
new_dirandold_inodeorold_dirandnew_inode. Otherwise inheritance of parent's encryption context will be broken.Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/namei.c | 9 +++++++++ 1 file changed, 9 insertions(+)Quoted 5 lines
fs/f2fs/namei.c static int f2fs_cross_rename(struct inode *old_dir, struct dentry
Quoted 5 lines
fs/f2fs/namei.c +0
-0@@ -754,6 +754,15 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry
*old_dentry,fs/f2fs/namei.c static int f2fs_cross_rename(struct inode *old_dir, struct dentry
Quoted 24 lines
fs/f2fs/namei.c static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, · line 773
Quoted 12 lines
fs/f2fs/namei.c +9
-0int old_nlink =0 , new_nlink =0 ;int err = -ENOENT ; +if ((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))) { + err = -EPERM ; + goto out; + } +Seems like we need this?
--- fs/f2fs/namei.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)fs/f2fs/namei.c +0
-0@@ -756,6 +756,21 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry
*old_dentry,Quoted 3 lines
fs/f2fs/namei.c +0
-0int old_nlink =0 , new_nlink =0 ;int err = -ENOENT ;
Quoted 16 lines
Quoted 4 lines
fs/f2fs/namei.c +4
-0+if (old_dir != new_dir) { +if (f2fs_encrypted_inode (new_dir) && + !f2fs_is_child_context_consistent_with_parent (new_dir, + old_inode)) {fs/f2fs/namei.c static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, · line 772
Quoted 10 lines
fs/f2fs/namei.c +10
-0+ err = -EPERM ; + goto out; + } +if (f2fs_encrypted_inode (old_dir) && + !f2fs_is_child_context_consistent_with_parent (old_dir, + new_inode)) { + err = -EPERM ; + goto out; + } + }It needs to sync with ext4 patch published by Ted.
No objection, please go ahead.
Previously, I remove f2fs_encrypted_inode(parent_inode) condition because in f2fs_is_child_context_consistent_with_parent we have the same verification.
/* no restrictions if the parent directory is not encrypted */ if (!f2fs_encrypted_inode(parent)) return 1;
Thanks,
Quoted 16 lines
Thanks,
Quoted 13 lines
fs/f2fs/namei.c +1
-1+f2fs_balance_fs (sbi); old_entry =f2fs_find_entry (old_dir, &old_dentry->d_name, &old_page); --2.1.1
------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
------------------------------------------------------------------------------