summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2017-11-14 19:28:42 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2017-11-15 08:30:19 -0800
commitead710b7d82dc9e8184e10871c155a3ed8b3f673 (patch)
tree578b94687f1eb5cd3c27f722c0d341f41a5688e6 /fs
parent812c60564ca721a2527ed069c9221ec348368fd7 (diff)
downloadlinux-ead710b7d82dc9e8184e10871c155a3ed8b3f673.tar.bz2
f2fs: deny accessing encryption policy if encryption is off
This patch adds missing feature check in encryption ioctl interface. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/f2fs/file.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 41a6f1f70416..25038cfc9217 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1928,6 +1928,9 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg)
{
struct inode *inode = file_inode(filp);
+ if (!f2fs_sb_has_crypto(inode->i_sb))
+ return -EOPNOTSUPP;
+
f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
return fscrypt_ioctl_set_policy(filp, (const void __user *)arg);
@@ -1935,6 +1938,8 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg)
static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg)
{
+ if (!f2fs_sb_has_crypto(file_inode(filp)->i_sb))
+ return -EOPNOTSUPP;
return fscrypt_ioctl_get_policy(filp, (void __user *)arg);
}