summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorHou Tao <houtao1@huawei.com>2019-02-09 11:54:20 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-02-15 00:32:10 +0300
commitc68fb6c809824d4f9b25357b1969d4631c5a8e01 (patch)
tree07ffb0359fddd3767ea9cd521f1e52fb29b9bad4 /fs
parent7e372f648d9efd8002e70845eedd752e2197c6c5 (diff)
downloadlinux-c68fb6c809824d4f9b25357b1969d4631c5a8e01.tar.xz
ubifs: Reject unsupported ioctl flags explicitly
commit 2fe8b2d5578d7d142982e3bf62e4c0caf8b8fe02 upstream. Reject unsupported ioctl flags explicitly, so the following command on a regular ubifs file will fail: chattr +d ubifs_file And xfstests generic/424 will pass. Signed-off-by: Hou Tao <houtao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ubifs/ioctl.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
index fdc311246807..55c7e3eb60e8 100644
--- a/fs/ubifs/ioctl.c
+++ b/fs/ubifs/ioctl.c
@@ -28,6 +28,11 @@
#include <linux/mount.h>
#include "ubifs.h"
+/* Need to be kept consistent with checked flags in ioctl2ubifs() */
+#define UBIFS_SUPPORTED_IOCTL_FLAGS \
+ (FS_COMPR_FL | FS_SYNC_FL | FS_APPEND_FL | \
+ FS_IMMUTABLE_FL | FS_DIRSYNC_FL)
+
/**
* ubifs_set_inode_flags - set VFS inode flags.
* @inode: VFS inode to set flags for
@@ -166,6 +171,9 @@ long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (get_user(flags, (int __user *) arg))
return -EFAULT;
+ if (flags & ~UBIFS_SUPPORTED_IOCTL_FLAGS)
+ return -EOPNOTSUPP;
+
if (!S_ISDIR(inode->i_mode))
flags &= ~FS_DIRSYNC_FL;