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: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
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;
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;