lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 9 Jul 2015 18:05:15 +0200 (CEST)
From:	Mikulas Patocka <mikulas@...bright.com>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
cc:	Al Viro <viro@...iv.linux.org.uk>, Ted Ts'o <tytso@...gle.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	linux-fsdevel <linux-fsdevel@...r.kernel.org>
Subject: [PATCH] ioctl_compat: handle FITRIM



On Sun, 28 Jun 2015, Linus Torvalds wrote:

> On Sun, Jun 28, 2015 at 6:16 AM, Mikulas Patocka <mikulas@...bright.com> wrote:
> > This patch adds support for fstrim to the HPFS filesystem.
> ...
> > +#ifdef CONFIG_COMPAT
> > +       .compat_ioctl   = hpfs_compat_ioctl,
> > +#endif
> ...
> > +#ifdef CONFIG_COMPAT
> > +       .compat_ioctl   = hpfs_compat_ioctl,
> > +#endif
> ...
> > +#ifdef CONFIG_COMPAT
> > +long hpfs_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg)
> > +{
> > +       return hpfs_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
> > +}
> > +#endif
> 
> Hmm. You've clearly copied this pattern from other filesystems, and so
> I can't really blame you, but this thing annoys me a lot.
> 
> Why isn't FITRIM just marked as a COMPATIBLE_IOCTL(), at which point
> the generic ioctl layer will do exactly the above translation for us?
> 
> Am I missing something?
> 
>                      Linus

Here I'm sending a patch that handles FITRIM in a generic way?

BTW. what happened with the other HPFS patches? They haven't been included 
in Linux 4.2-rc1.


From: Mikulas Patocka <mikulas@...bright.com>

The FITRIM ioctl has the same arguments on 32-bit and 64-bit
architectures, so we can add it to the list of compatible ioctls and drop
it from compat_ioctl method of various filesystems.

Signed-off-by: Mikulas Patocka <mpatocka@...hat.com>

---
 fs/compat_ioctl.c  |    1 +
 fs/ecryptfs/file.c |    1 -
 fs/ext4/ioctl.c    |    1 -
 fs/hpfs/dir.c      |    3 ---
 fs/hpfs/file.c     |    3 ---
 fs/hpfs/super.c    |    7 -------
 fs/jfs/ioctl.c     |    4 ----
 fs/nilfs2/ioctl.c  |    1 -
 fs/ocfs2/ioctl.c   |    1 -
 9 files changed, 1 insertion(+), 21 deletions(-)

Index: linux-4.2-rc1/fs/compat_ioctl.c
===================================================================
--- linux-4.2-rc1.orig/fs/compat_ioctl.c	2015-07-09 16:17:16.000000000 +0200
+++ linux-4.2-rc1/fs/compat_ioctl.c	2015-07-09 16:18:50.000000000 +0200
@@ -896,6 +896,7 @@ COMPATIBLE_IOCTL(FIGETBSZ)
 /* 'X' - originally XFS but some now in the VFS */
 COMPATIBLE_IOCTL(FIFREEZE)
 COMPATIBLE_IOCTL(FITHAW)
+COMPATIBLE_IOCTL(FITRIM)
 COMPATIBLE_IOCTL(KDGETKEYCODE)
 COMPATIBLE_IOCTL(KDSETKEYCODE)
 COMPATIBLE_IOCTL(KDGKBTYPE)
Index: linux-4.2-rc1/fs/ecryptfs/file.c
===================================================================
--- linux-4.2-rc1.orig/fs/ecryptfs/file.c	2015-07-09 16:13:54.000000000 +0200
+++ linux-4.2-rc1/fs/ecryptfs/file.c	2015-07-09 16:14:05.000000000 +0200
@@ -325,7 +325,6 @@ ecryptfs_compat_ioctl(struct file *file,
 		return rc;
 
 	switch (cmd) {
-	case FITRIM:
 	case FS_IOC32_GETFLAGS:
 	case FS_IOC32_SETFLAGS:
 	case FS_IOC32_GETVERSION:
Index: linux-4.2-rc1/fs/ext4/ioctl.c
===================================================================
--- linux-4.2-rc1.orig/fs/ext4/ioctl.c	2015-07-09 16:16:38.000000000 +0200
+++ linux-4.2-rc1/fs/ext4/ioctl.c	2015-07-09 16:16:45.000000000 +0200
@@ -755,7 +755,6 @@ long ext4_compat_ioctl(struct file *file
 		return err;
 	}
 	case EXT4_IOC_MOVE_EXT:
-	case FITRIM:
 	case EXT4_IOC_RESIZE_FS:
 	case EXT4_IOC_PRECACHE_EXTENTS:
 	case EXT4_IOC_SET_ENCRYPTION_POLICY:
Index: linux-4.2-rc1/fs/hpfs/dir.c
===================================================================
--- linux-4.2-rc1.orig/fs/hpfs/dir.c	2015-07-09 16:15:22.000000000 +0200
+++ linux-4.2-rc1/fs/hpfs/dir.c	2015-07-09 16:15:26.000000000 +0200
@@ -328,7 +328,4 @@ const struct file_operations hpfs_dir_op
 	.release	= hpfs_dir_release,
 	.fsync		= hpfs_file_fsync,
 	.unlocked_ioctl	= hpfs_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl	= hpfs_compat_ioctl,
-#endif
 };
Index: linux-4.2-rc1/fs/hpfs/file.c
===================================================================
--- linux-4.2-rc1.orig/fs/hpfs/file.c	2015-07-09 16:15:30.000000000 +0200
+++ linux-4.2-rc1/fs/hpfs/file.c	2015-07-09 16:15:33.000000000 +0200
@@ -204,9 +204,6 @@ const struct file_operations hpfs_file_o
 	.fsync		= hpfs_file_fsync,
 	.splice_read	= generic_file_splice_read,
 	.unlocked_ioctl	= hpfs_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl	= hpfs_compat_ioctl,
-#endif
 };
 
 const struct inode_operations hpfs_file_iops =
Index: linux-4.2-rc1/fs/hpfs/super.c
===================================================================
--- linux-4.2-rc1.orig/fs/hpfs/super.c	2015-07-09 16:14:53.000000000 +0200
+++ linux-4.2-rc1/fs/hpfs/super.c	2015-07-09 16:15:12.000000000 +0200
@@ -228,13 +228,6 @@ long hpfs_ioctl(struct file *file, unsig
 	}
 }
 
-#ifdef CONFIG_COMPAT
-long hpfs_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg)
-{
-	return hpfs_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
-}
-#endif
-
 
 static struct kmem_cache * hpfs_inode_cachep;
 
Index: linux-4.2-rc1/fs/jfs/ioctl.c
===================================================================
--- linux-4.2-rc1.orig/fs/jfs/ioctl.c	2015-07-09 16:16:52.000000000 +0200
+++ linux-4.2-rc1/fs/jfs/ioctl.c	2015-07-09 16:17:03.000000000 +0200
@@ -180,10 +180,6 @@ long jfs_compat_ioctl(struct file *filp,
 	case JFS_IOC_SETFLAGS32:
 		cmd = JFS_IOC_SETFLAGS;
 		break;
-	case FITRIM:
-		cmd = FITRIM;
-		break;
-	}
 	return jfs_ioctl(filp, cmd, arg);
 }
 #endif
Index: linux-4.2-rc1/fs/nilfs2/ioctl.c
===================================================================
--- linux-4.2-rc1.orig/fs/nilfs2/ioctl.c	2015-07-09 16:13:37.000000000 +0200
+++ linux-4.2-rc1/fs/nilfs2/ioctl.c	2015-07-09 16:13:47.000000000 +0200
@@ -1369,7 +1369,6 @@ long nilfs_compat_ioctl(struct file *fil
 	case NILFS_IOCTL_SYNC:
 	case NILFS_IOCTL_RESIZE:
 	case NILFS_IOCTL_SET_ALLOC_RANGE:
-	case FITRIM:
 		break;
 	default:
 		return -ENOIOCTLCMD;
Index: linux-4.2-rc1/fs/ocfs2/ioctl.c
===================================================================
--- linux-4.2-rc1.orig/fs/ocfs2/ioctl.c	2015-07-09 16:14:20.000000000 +0200
+++ linux-4.2-rc1/fs/ocfs2/ioctl.c	2015-07-09 16:14:25.000000000 +0200
@@ -980,7 +980,6 @@ long ocfs2_compat_ioctl(struct file *fil
 	case OCFS2_IOC_GROUP_EXTEND:
 	case OCFS2_IOC_GROUP_ADD:
 	case OCFS2_IOC_GROUP_ADD64:
-	case FITRIM:
 		break;
 	case OCFS2_IOC_REFLINK:
 		if (copy_from_user(&args, argp, sizeof(args)))
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists