summaryrefslogtreecommitdiffstats
path: root/fs/ubifs/ioctl.c
diff options
context:
space:
mode:
authorHou Tao <houtao1@huawei.com>2019-02-09 03:54:20 -0500
committerRichard Weinberger <richard@nod.at>2019-02-24 05:40:46 -0500
commit2fe8b2d5578d7d142982e3bf62e4c0caf8b8fe02 (patch)
tree5c0cc1ed6256c83c01dabbec7b2a75fc4148c191 /fs/ubifs/ioctl.c
parent663586c0a8929db81e617c775823efb9d65f2bc2 (diff)
ubifs: Reject unsupported ioctl flags explicitly
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>
Diffstat (limited to 'fs/ubifs/ioctl.c')
-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 0164bcc827f8..daf9f93e15de 100644
--- a/fs/ubifs/ioctl.c
+++ b/fs/ubifs/ioctl.c
@@ -28,6 +28,11 @@
28#include <linux/mount.h> 28#include <linux/mount.h>
29#include "ubifs.h" 29#include "ubifs.h"
30 30
31/* Need to be kept consistent with checked flags in ioctl2ubifs() */
32#define UBIFS_SUPPORTED_IOCTL_FLAGS \
33 (FS_COMPR_FL | FS_SYNC_FL | FS_APPEND_FL | \
34 FS_IMMUTABLE_FL | FS_DIRSYNC_FL)
35
31/** 36/**
32 * ubifs_set_inode_flags - set VFS inode flags. 37 * ubifs_set_inode_flags - set VFS inode flags.
33 * @inode: VFS inode to set flags for 38 * @inode: VFS inode to set flags for
@@ -169,6 +174,9 @@ long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
169 if (get_user(flags, (int __user *) arg)) 174 if (get_user(flags, (int __user *) arg))
170 return -EFAULT; 175 return -EFAULT;
171 176
177 if (flags & ~UBIFS_SUPPORTED_IOCTL_FLAGS)
178 return -EOPNOTSUPP;
179
172 if (!S_ISDIR(inode->i_mode)) 180 if (!S_ISDIR(inode->i_mode))
173 flags &= ~FS_DIRSYNC_FL; 181 flags &= ~FS_DIRSYNC_FL;
174 182