Skip to contentSkip to conversation

ubifs: reject unsupported ioctl flags explicitly

PATCH In review Hou Tao 2 participants 4 messages Feb 9, 2019 – Feb 14, 2019

Subsystems (2)
lore
Share & tools
lore

Hou Tao

author
#0 lore raw

PATCH 1/1 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.

---
 fs/ubifs/ioctl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/ubifs/ioctl.c +8 -0
index 0164bcc827f8..daf9f93e15de 100644
@@ -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
@@ -169,6 +174,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;
 
Signature · 6 lines
2.16.2.dirty


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
author
#1 lore raw

ping ?

Quoted 29 lines · Hou Tao

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.

---
 fs/ubifs/ioctl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/ubifs/ioctl.c +5 -0
index 0164bcc827f8..daf9f93e15de 100644
@@ -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

fs/ubifs/ioctl.c long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 182

Quoted 9 lines
fs/ubifs/ioctl.c +3 -0
@@ -169,6 +174,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;
 

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#3 lore raw
In reply to Hou Tao

Am Samstag, 9. Februar 2019, 09:54:20 CET schrieb Hou Tao:

Quoted 29 lines

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.

---
 fs/ubifs/ioctl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/ubifs/ioctl.c +5 -0
index 0164bcc827f8..daf9f93e15de 100644
@@ -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

fs/ubifs/ioctl.c long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 182

Quoted 9 lines
fs/ubifs/ioctl.c +3 -0
@@ -169,6 +174,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;
 

Makes sense, will queue for the next merge window. :-)

Thanks,
//richard

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/