summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/crypto_policy.c
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2015-05-27 09:27:49 +0200
committerJaegeuk Kim <jaegeuk@kernel.org>2015-06-02 01:21:07 +0200
commit4637fd11fff7ddca1a1d7d27d2fbfc4dcb8e9791 (patch)
tree0a619be7025b1b291653962eb580d77ed04f150b /fs/f2fs/crypto_policy.c
parentf2fs crypto: allow setting encryption policy once (diff)
downloadlinux-4637fd11fff7ddca1a1d7d27d2fbfc4dcb8e9791.tar.xz
linux-4637fd11fff7ddca1a1d7d27d2fbfc4dcb8e9791.zip
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: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/crypto_policy.c')
-rw-r--r--fs/f2fs/crypto_policy.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/f2fs/crypto_policy.c b/fs/f2fs/crypto_policy.c
index 30b0b73d4200..d4a96af513c2 100644
--- a/fs/f2fs/crypto_policy.c
+++ b/fs/f2fs/crypto_policy.c
@@ -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;