Commit 4637fd11 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim
Browse files

f2fs crypto: 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.
Signed-off-by: default avatarChao Yu <>
Signed-off-by: default avatarJaegeuk Kim <>
parent 81b0a8ff
...@@ -92,6 +92,9 @@ int f2fs_process_policy(const struct f2fs_encryption_policy *policy, ...@@ -92,6 +92,9 @@ int f2fs_process_policy(const struct f2fs_encryption_policy *policy,
if (policy->version != 0) if (policy->version != 0)
return -EINVAL; return -EINVAL;
if (!S_ISDIR(inode->i_mode))
return -EINVAL;
if (!f2fs_inode_has_encryption_context(inode)) { if (!f2fs_inode_has_encryption_context(inode)) {
if (!f2fs_empty_dir(inode)) if (!f2fs_empty_dir(inode))
return -ENOTEMPTY; return -ENOTEMPTY;
...@@ -1395,12 +1395,6 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg) ...@@ -1395,12 +1395,6 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg)
sizeof(policy))) sizeof(policy)))
return -EFAULT; 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); return f2fs_process_policy(&policy, inode);
#else #else
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment