[E/F][PATCH] gfs2: add compat_ioctl support

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[E/F][PATCH] gfs2: add compat_ioctl support

Mauricio Faria de Oliveira-3
From: Arnd Bergmann <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1859827

Out of the four ioctl commands supported on gfs2, only FITRIM
works in compat mode.

Add a proper handler based on the ext4 implementation.

Fixes: 6ddc5c3ddf25 ("gfs2: getlabel support")
Reviewed-by: Bob Peterson <[hidden email]>
Cc: Andreas Gruenbacher <[hidden email]>
Signed-off-by: Arnd Bergmann <[hidden email]>
(cherry picked from commit 8d0980704842e8a68df2c3164c1c165e5c7ebc08)
Signed-off-by: Mauricio Faria de Oliveira <[hidden email]>
---
 fs/gfs2/file.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 52fa1ef8400b..92a42c3bbbcd 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -6,6 +6,7 @@
 
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/compat.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
 #include <linux/pagemap.h>
@@ -354,6 +355,31 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
  return -ENOTTY;
 }
 
+#ifdef CONFIG_COMPAT
+static long gfs2_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ switch(cmd) {
+ /* These are just misnamed, they actually get/put from/to user an int */
+ case FS_IOC32_GETFLAGS:
+ cmd = FS_IOC_GETFLAGS;
+ break;
+ case FS_IOC32_SETFLAGS:
+ cmd = FS_IOC_SETFLAGS;
+ break;
+ /* Keep this list in sync with gfs2_ioctl */
+ case FITRIM:
+ case FS_IOC_GETFSLABEL:
+ break;
+ default:
+ return -ENOIOCTLCMD;
+ }
+
+ return gfs2_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
+}
+#else
+#define gfs2_compat_ioctl NULL
+#endif
+
 /**
  * gfs2_size_hint - Give a hint to the size of a write request
  * @filep: The struct file
@@ -1294,6 +1320,7 @@ const struct file_operations gfs2_file_fops = {
  .write_iter = gfs2_file_write_iter,
  .iopoll = iomap_dio_iopoll,
  .unlocked_ioctl = gfs2_ioctl,
+ .compat_ioctl = gfs2_compat_ioctl,
  .mmap = gfs2_mmap,
  .open = gfs2_open,
  .release = gfs2_release,
@@ -1309,6 +1336,7 @@ const struct file_operations gfs2_file_fops = {
 const struct file_operations gfs2_dir_fops = {
  .iterate_shared = gfs2_readdir,
  .unlocked_ioctl = gfs2_ioctl,
+ .compat_ioctl = gfs2_compat_ioctl,
  .open = gfs2_open,
  .release = gfs2_release,
  .fsync = gfs2_fsync,
@@ -1325,6 +1353,7 @@ const struct file_operations gfs2_file_fops_nolock = {
  .write_iter = gfs2_file_write_iter,
  .iopoll = iomap_dio_iopoll,
  .unlocked_ioctl = gfs2_ioctl,
+ .compat_ioctl = gfs2_compat_ioctl,
  .mmap = gfs2_mmap,
  .open = gfs2_open,
  .release = gfs2_release,
@@ -1338,6 +1367,7 @@ const struct file_operations gfs2_file_fops_nolock = {
 const struct file_operations gfs2_dir_fops_nolock = {
  .iterate_shared = gfs2_readdir,
  .unlocked_ioctl = gfs2_ioctl,
+ .compat_ioctl = gfs2_compat_ioctl,
  .open = gfs2_open,
  .release = gfs2_release,
  .fsync = gfs2_fsync,
--
2.20.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [E/F][PATCH] gfs2: add compat_ioctl support

Stefan Bader-2
On 15.01.20 18:42, Mauricio Faria de Oliveira wrote:

> From: Arnd Bergmann <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/bugs/1859827
>
> Out of the four ioctl commands supported on gfs2, only FITRIM
> works in compat mode.
>
> Add a proper handler based on the ext4 implementation.
>
> Fixes: 6ddc5c3ddf25 ("gfs2: getlabel support")
> Reviewed-by: Bob Peterson <[hidden email]>
> Cc: Andreas Gruenbacher <[hidden email]>
> Signed-off-by: Arnd Bergmann <[hidden email]>
> (cherry picked from commit 8d0980704842e8a68df2c3164c1c165e5c7ebc08)
> Signed-off-by: Mauricio Faria de Oliveira <[hidden email]>
Acked-by: Stefan Bader <[hidden email]>

> ---
>  fs/gfs2/file.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
>
> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
> index 52fa1ef8400b..92a42c3bbbcd 100644
> --- a/fs/gfs2/file.c
> +++ b/fs/gfs2/file.c
> @@ -6,6 +6,7 @@
>  
>  #include <linux/slab.h>
>  #include <linux/spinlock.h>
> +#include <linux/compat.h>
>  #include <linux/completion.h>
>  #include <linux/buffer_head.h>
>  #include <linux/pagemap.h>
> @@ -354,6 +355,31 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>   return -ENOTTY;
>  }
>  
> +#ifdef CONFIG_COMPAT
> +static long gfs2_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> +{
> + switch(cmd) {
> + /* These are just misnamed, they actually get/put from/to user an int */
> + case FS_IOC32_GETFLAGS:
> + cmd = FS_IOC_GETFLAGS;
> + break;
> + case FS_IOC32_SETFLAGS:
> + cmd = FS_IOC_SETFLAGS;
> + break;
> + /* Keep this list in sync with gfs2_ioctl */
> + case FITRIM:
> + case FS_IOC_GETFSLABEL:
> + break;
> + default:
> + return -ENOIOCTLCMD;
> + }
> +
> + return gfs2_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
> +}
> +#else
> +#define gfs2_compat_ioctl NULL
> +#endif
> +
>  /**
>   * gfs2_size_hint - Give a hint to the size of a write request
>   * @filep: The struct file
> @@ -1294,6 +1320,7 @@ const struct file_operations gfs2_file_fops = {
>   .write_iter = gfs2_file_write_iter,
>   .iopoll = iomap_dio_iopoll,
>   .unlocked_ioctl = gfs2_ioctl,
> + .compat_ioctl = gfs2_compat_ioctl,
>   .mmap = gfs2_mmap,
>   .open = gfs2_open,
>   .release = gfs2_release,
> @@ -1309,6 +1336,7 @@ const struct file_operations gfs2_file_fops = {
>  const struct file_operations gfs2_dir_fops = {
>   .iterate_shared = gfs2_readdir,
>   .unlocked_ioctl = gfs2_ioctl,
> + .compat_ioctl = gfs2_compat_ioctl,
>   .open = gfs2_open,
>   .release = gfs2_release,
>   .fsync = gfs2_fsync,
> @@ -1325,6 +1353,7 @@ const struct file_operations gfs2_file_fops_nolock = {
>   .write_iter = gfs2_file_write_iter,
>   .iopoll = iomap_dio_iopoll,
>   .unlocked_ioctl = gfs2_ioctl,
> + .compat_ioctl = gfs2_compat_ioctl,
>   .mmap = gfs2_mmap,
>   .open = gfs2_open,
>   .release = gfs2_release,
> @@ -1338,6 +1367,7 @@ const struct file_operations gfs2_file_fops_nolock = {
>  const struct file_operations gfs2_dir_fops_nolock = {
>   .iterate_shared = gfs2_readdir,
>   .unlocked_ioctl = gfs2_ioctl,
> + .compat_ioctl = gfs2_compat_ioctl,
>   .open = gfs2_open,
>   .release = gfs2_release,
>   .fsync = gfs2_fsync,
>


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

ACK: [E/F][PATCH] gfs2: add compat_ioctl support

Connor Kuehl
In reply to this post by Mauricio Faria de Oliveira-3
On 1/15/20 9:42 AM, Mauricio Faria de Oliveira wrote:

> From: Arnd Bergmann <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/bugs/1859827
>
> Out of the four ioctl commands supported on gfs2, only FITRIM
> works in compat mode.
>
> Add a proper handler based on the ext4 implementation.
>
> Fixes: 6ddc5c3ddf25 ("gfs2: getlabel support")
> Reviewed-by: Bob Peterson <[hidden email]>
> Cc: Andreas Gruenbacher <[hidden email]>
> Signed-off-by: Arnd Bergmann <[hidden email]>
> (cherry picked from commit 8d0980704842e8a68df2c3164c1c165e5c7ebc08)
> Signed-off-by: Mauricio Faria de Oliveira <[hidden email]>

Acked-by: Connor Kuehl <[hidden email]>

> ---
>   fs/gfs2/file.c | 30 ++++++++++++++++++++++++++++++
>   1 file changed, 30 insertions(+)
>
> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
> index 52fa1ef8400b..92a42c3bbbcd 100644
> --- a/fs/gfs2/file.c
> +++ b/fs/gfs2/file.c
> @@ -6,6 +6,7 @@
>  
>   #include <linux/slab.h>
>   #include <linux/spinlock.h>
> +#include <linux/compat.h>
>   #include <linux/completion.h>
>   #include <linux/buffer_head.h>
>   #include <linux/pagemap.h>
> @@ -354,6 +355,31 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>   return -ENOTTY;
>   }
>  
> +#ifdef CONFIG_COMPAT
> +static long gfs2_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> +{
> + switch(cmd) {
> + /* These are just misnamed, they actually get/put from/to user an int */
> + case FS_IOC32_GETFLAGS:
> + cmd = FS_IOC_GETFLAGS;
> + break;
> + case FS_IOC32_SETFLAGS:
> + cmd = FS_IOC_SETFLAGS;
> + break;
> + /* Keep this list in sync with gfs2_ioctl */
> + case FITRIM:
> + case FS_IOC_GETFSLABEL:
> + break;
> + default:
> + return -ENOIOCTLCMD;
> + }
> +
> + return gfs2_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
> +}
> +#else
> +#define gfs2_compat_ioctl NULL
> +#endif
> +
>   /**
>    * gfs2_size_hint - Give a hint to the size of a write request
>    * @filep: The struct file
> @@ -1294,6 +1320,7 @@ const struct file_operations gfs2_file_fops = {
>   .write_iter = gfs2_file_write_iter,
>   .iopoll = iomap_dio_iopoll,
>   .unlocked_ioctl = gfs2_ioctl,
> + .compat_ioctl = gfs2_compat_ioctl,
>   .mmap = gfs2_mmap,
>   .open = gfs2_open,
>   .release = gfs2_release,
> @@ -1309,6 +1336,7 @@ const struct file_operations gfs2_file_fops = {
>   const struct file_operations gfs2_dir_fops = {
>   .iterate_shared = gfs2_readdir,
>   .unlocked_ioctl = gfs2_ioctl,
> + .compat_ioctl = gfs2_compat_ioctl,
>   .open = gfs2_open,
>   .release = gfs2_release,
>   .fsync = gfs2_fsync,
> @@ -1325,6 +1353,7 @@ const struct file_operations gfs2_file_fops_nolock = {
>   .write_iter = gfs2_file_write_iter,
>   .iopoll = iomap_dio_iopoll,
>   .unlocked_ioctl = gfs2_ioctl,
> + .compat_ioctl = gfs2_compat_ioctl,
>   .mmap = gfs2_mmap,
>   .open = gfs2_open,
>   .release = gfs2_release,
> @@ -1338,6 +1367,7 @@ const struct file_operations gfs2_file_fops_nolock = {
>   const struct file_operations gfs2_dir_fops_nolock = {
>   .iterate_shared = gfs2_readdir,
>   .unlocked_ioctl = gfs2_ioctl,
> + .compat_ioctl = gfs2_compat_ioctl,
>   .open = gfs2_open,
>   .release = gfs2_release,
>   .fsync = gfs2_fsync,
>


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED[F]: [E/F][PATCH] gfs2: add compat_ioctl support

Seth Forshee
In reply to this post by Mauricio Faria de Oliveira-3
On Wed, Jan 15, 2020 at 02:42:36PM -0300, Mauricio Faria de Oliveira wrote:

> From: Arnd Bergmann <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/bugs/1859827
>
> Out of the four ioctl commands supported on gfs2, only FITRIM
> works in compat mode.
>
> Add a proper handler based on the ext4 implementation.
>
> Fixes: 6ddc5c3ddf25 ("gfs2: getlabel support")
> Reviewed-by: Bob Peterson <[hidden email]>
> Cc: Andreas Gruenbacher <[hidden email]>
> Signed-off-by: Arnd Bergmann <[hidden email]>
> (cherry picked from commit 8d0980704842e8a68df2c3164c1c165e5c7ebc08)
> Signed-off-by: Mauricio Faria de Oliveira <[hidden email]>

Applied to focal/master-next, thanks!

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED(E): [E/F][PATCH] gfs2: add compat_ioctl support

Khaled Elmously
In reply to this post by Mauricio Faria de Oliveira-3
On 2020-01-15 14:42:36 , Mauricio Faria de Oliveira wrote:

> From: Arnd Bergmann <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/bugs/1859827
>
> Out of the four ioctl commands supported on gfs2, only FITRIM
> works in compat mode.
>
> Add a proper handler based on the ext4 implementation.
>
> Fixes: 6ddc5c3ddf25 ("gfs2: getlabel support")
> Reviewed-by: Bob Peterson <[hidden email]>
> Cc: Andreas Gruenbacher <[hidden email]>
> Signed-off-by: Arnd Bergmann <[hidden email]>
> (cherry picked from commit 8d0980704842e8a68df2c3164c1c165e5c7ebc08)
> Signed-off-by: Mauricio Faria de Oliveira <[hidden email]>
> ---
>  fs/gfs2/file.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
>
> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
> index 52fa1ef8400b..92a42c3bbbcd 100644
> --- a/fs/gfs2/file.c
> +++ b/fs/gfs2/file.c
> @@ -6,6 +6,7 @@
>  
>  #include <linux/slab.h>
>  #include <linux/spinlock.h>
> +#include <linux/compat.h>
>  #include <linux/completion.h>
>  #include <linux/buffer_head.h>
>  #include <linux/pagemap.h>
> @@ -354,6 +355,31 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>   return -ENOTTY;
>  }
>  
> +#ifdef CONFIG_COMPAT
> +static long gfs2_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> +{
> + switch(cmd) {
> + /* These are just misnamed, they actually get/put from/to user an int */
> + case FS_IOC32_GETFLAGS:
> + cmd = FS_IOC_GETFLAGS;
> + break;
> + case FS_IOC32_SETFLAGS:
> + cmd = FS_IOC_SETFLAGS;
> + break;
> + /* Keep this list in sync with gfs2_ioctl */
> + case FITRIM:
> + case FS_IOC_GETFSLABEL:
> + break;
> + default:
> + return -ENOIOCTLCMD;
> + }
> +
> + return gfs2_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
> +}
> +#else
> +#define gfs2_compat_ioctl NULL
> +#endif
> +
>  /**
>   * gfs2_size_hint - Give a hint to the size of a write request
>   * @filep: The struct file
> @@ -1294,6 +1320,7 @@ const struct file_operations gfs2_file_fops = {
>   .write_iter = gfs2_file_write_iter,
>   .iopoll = iomap_dio_iopoll,
>   .unlocked_ioctl = gfs2_ioctl,
> + .compat_ioctl = gfs2_compat_ioctl,
>   .mmap = gfs2_mmap,
>   .open = gfs2_open,
>   .release = gfs2_release,
> @@ -1309,6 +1336,7 @@ const struct file_operations gfs2_file_fops = {
>  const struct file_operations gfs2_dir_fops = {
>   .iterate_shared = gfs2_readdir,
>   .unlocked_ioctl = gfs2_ioctl,
> + .compat_ioctl = gfs2_compat_ioctl,
>   .open = gfs2_open,
>   .release = gfs2_release,
>   .fsync = gfs2_fsync,
> @@ -1325,6 +1353,7 @@ const struct file_operations gfs2_file_fops_nolock = {
>   .write_iter = gfs2_file_write_iter,
>   .iopoll = iomap_dio_iopoll,
>   .unlocked_ioctl = gfs2_ioctl,
> + .compat_ioctl = gfs2_compat_ioctl,
>   .mmap = gfs2_mmap,
>   .open = gfs2_open,
>   .release = gfs2_release,
> @@ -1338,6 +1367,7 @@ const struct file_operations gfs2_file_fops_nolock = {
>  const struct file_operations gfs2_dir_fops_nolock = {
>   .iterate_shared = gfs2_readdir,
>   .unlocked_ioctl = gfs2_ioctl,
> + .compat_ioctl = gfs2_compat_ioctl,
>   .open = gfs2_open,
>   .release = gfs2_release,
>   .fsync = gfs2_fsync,
> --
> 2.20.1
>
>
> --
> kernel-team mailing list
> [hidden email]
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team