Skip to contentSkip to conversation

f2fs crypto: check dir entry just for directory

PATCH In review Chao Yu 1 participant 2 messages May 25, 2015 – May 27, 2015 F2FS file system

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 2/3 f2fs crypto: check dir entry just for directory

This patch fixes to add a judgement condition to verify type of the target inode before empty directory verification.

So wrong verification could be avoided for non-directory inode.

---
 fs/f2fs/crypto_policy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/crypto_policy.c +1 -1
index bef254b..56b2ac0 100644
@@ -93,7 +93,7 @@ int f2fs_process_policy(const struct f2fs_encryption_policy *policy,
 		return -EINVAL;
 
 	if (!f2fs_inode_has_encryption_context(inode)) {
-		if (!f2fs_empty_dir(inode))
+		if (S_ISDIR(inode->i_mode) && !f2fs_empty_dir(inode))
 			return -ENOTEMPTY;
 		return f2fs_create_encryption_context_from_policy(inode,
 								  policy);
Signature · 10 lines
2.3.0



------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
author
#1 lore raw

Hi all,

Quoted 11 lines

-----Original Message-----
From: Chao Yu [mailto:[email protected]]
Sent: Monday, May 25, 2015 6:08 PM
To: Jaegeuk Kim; Changman Lee
Cc: [email protected]; [email protected]
Subject: [f2fs-dev] [PATCH 2/3] f2fs crypto: check dir entry just for directory

This patch fixes to add a judgement condition to verify type of the target inode before empty directory verification.

So wrong verification could be avoided for non-directory inode.

Proposal for ext4 encryption indicated that encryption policy will only be set to an directory in below link:

https://lwn.net/Articles/639427/

So the previous patch could not fix the issue exactly, I'd like to use the below patch instead.

Quoted 1 line

From 28540d2ab2150e586a96314336651eea74f48c7d Mon Sep 17 00:00:00 2001

From: Chao Yu <[email protected]>
Date: Wed, 27 May 2015 14:51:52 +0800
Subject: [PATCH] f2fs: do not set encryption policy for non-directory by ioctl

Encryption policy should only be set to an empty directory through ioctl, This patch add a judgement condition to verify type of the target inode to avoid incorrectly configuring for non-directory.

Additionally, remove unneeded inline data conversion since regular or symlink file should not be processed here.

---
 fs/f2fs/crypto_policy.c | 3 +++
 fs/f2fs/file.c          | 6 ------
 2 files changed, 3 insertions(+), 6 deletions(-)
fs/f2fs/crypto_policy.c +3 -0
index 30b0b73..d4a96af 100644
@@ -92,6 +92,9 @@ int f2fs_process_policy(const struct f2fs_encryption_policy *policy,
 	if (policy->version != 0)
 		return -EINVAL;
 
+	if (!S_ISDIR(inode->i_mode))
+		return -EINVAL;
+
 	if (!f2fs_inode_has_encryption_context(inode)) {
 		if (!f2fs_empty_dir(inode))
 			return -ENOTEMPTY;
fs/f2fs/file.c +0 -6
index af5ef5f..4d42d66 100644
@@ -1485,12 +1485,6 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg)
 				sizeof(policy)))
 		return -EFAULT;
 
-	if (f2fs_has_inline_data(inode)) {
-		int ret = f2fs_convert_inline_inode(inode);
-		if (ret)
-			return ret;
-	}
-
 	return f2fs_process_policy(&policy, inode);
 #else
 	return -EOPNOTSUPP;
Signature · 1 line
2.3.3