Linux-mtd Archive on lore.kernel.org
 help / Atom feed
* [PATCH] ubifs: reject unsupported ioctl flags explicitly
@ 2019-02-09  8:54 Hou Tao
  2019-02-13  6:50 ` Hou Tao
  2019-02-14  7:43 ` Richard Weinberger
  0 siblings, 2 replies; 4+ messages in thread
From: Hou Tao @ 2019-02-09  8:54 UTC (permalink / raw)
  To: linux-mtd; +Cc: richard, houtao1, adrian.hunter, dedekind1

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>
---
 fs/ubifs/ioctl.c | 8 ++++++++
 1 file changed, 8 insertions(+)

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 @@
 #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;
 
-- 
2.16.2.dirty


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ubifs: reject unsupported ioctl flags explicitly
  2019-02-09  8:54 [PATCH] ubifs: reject unsupported ioctl flags explicitly Hou Tao
@ 2019-02-13  6:50 ` Hou Tao
  2019-02-13  9:37   ` Richard Weinberger
  2019-02-14  7:43 ` Richard Weinberger
  1 sibling, 1 reply; 4+ messages in thread
From: Hou Tao @ 2019-02-13  6:50 UTC (permalink / raw)
  To: linux-mtd; +Cc: richard, adrian.hunter, dedekind1

ping ?

On 2019/2/9 16:54, Hou Tao wrote:
> 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>
> ---
>  fs/ubifs/ioctl.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> 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 @@
>  #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;
>  
> 


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ubifs: reject unsupported ioctl flags explicitly
  2019-02-13  6:50 ` Hou Tao
@ 2019-02-13  9:37   ` Richard Weinberger
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Weinberger @ 2019-02-13  9:37 UTC (permalink / raw)
  To: Hou Tao; +Cc: linux-mtd, adrian.hunter, dedekind1

Am Mittwoch, 13. Februar 2019, 07:50:42 CET schrieb Hou Tao:
> ping ?

No need to panic. Just returned from vacation and still didn't reach
to bottom of my mail pile....
 
Thanks,
//richard



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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ubifs: reject unsupported ioctl flags explicitly
  2019-02-09  8:54 [PATCH] ubifs: reject unsupported ioctl flags explicitly Hou Tao
  2019-02-13  6:50 ` Hou Tao
@ 2019-02-14  7:43 ` Richard Weinberger
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Weinberger @ 2019-02-14  7:43 UTC (permalink / raw)
  To: Hou Tao; +Cc: linux-mtd, adrian.hunter, dedekind1

Am Samstag, 9. Februar 2019, 09:54:20 CET schrieb 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.
> 
> Signed-off-by: Hou Tao <houtao1@huawei.com>
> ---
>  fs/ubifs/ioctl.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> 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 @@
>  #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;
>  
> 

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

Thanks,
//richard




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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-09  8:54 [PATCH] ubifs: reject unsupported ioctl flags explicitly Hou Tao
2019-02-13  6:50 ` Hou Tao
2019-02-13  9:37   ` Richard Weinberger
2019-02-14  7:43 ` Richard Weinberger

Linux-mtd Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
		linux-mtd@lists.infradead.org linux-mtd@archiver.kernel.org
	public-inbox-index linux-mtd


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd


AGPL code for this site: git clone https://public-inbox.org/ public-inbox