mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] f2fs: don't allow rename unencrypted file to encrypted directory
@ 2017-03-08 12:08 Chao Yu
  2017-03-08 13:35 ` [f2fs-dev] " Kinglong Mee
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chao Yu @ 2017-03-08 12:08 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao, Chao Yu

In commit d9cdc9033181 ("ext4 crypto: enforce context consistency") we
declared that:

2) All files or directories in a directory must be protected using the
    same key as their containing directory.

But in f2fs_cross_rename there is a vulnerability that allow to cross
rename unencrypted file into encrypted directory, it needs to be refused.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/namei.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 25c073f6c7d4..8de684b84cb9 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -855,6 +855,10 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 			!fscrypt_has_encryption_key(new_dir)))
 		return -ENOKEY;
 
+	if (f2fs_encrypted_inode(old_dir) && !f2fs_encrypted_inode(new_inode) ||
+		f2fs_encrypted_inode(new_dir) && !f2fs_encrypted_inode(old_inode))
+		return -EPERM;
+
 	if ((f2fs_encrypted_inode(old_dir) || f2fs_encrypted_inode(new_dir)) &&
 			(old_dir != new_dir) &&
 			(!fscrypt_has_permitted_context(new_dir, old_inode) ||
-- 
2.8.2.295.g3f1c1d0

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-10 22:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-08 12:08 [PATCH] f2fs: don't allow rename unencrypted file to encrypted directory Chao Yu
2017-03-08 13:35 ` [f2fs-dev] " Kinglong Mee
2017-03-09  1:33   ` Chao Yu
2017-03-10 21:49 ` kbuild test robot
2017-03-10 22:14 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®