]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: bugfix: handle FS_IOC32_{GETFLAGS,SETFLAGS,GETVERSION} in btrfs_ioctl
authorLuke Dashjr <luke@dashjr.org>
Thu, 29 Oct 2015 08:22:21 +0000 (08:22 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Jun 2016 01:18:54 +0000 (18:18 -0700)
commit 4c63c2454eff996c5e27991221106eb511f7db38 upstream.

32-bit ioctl uses these rather than the regular FS_IOC_* versions. They can
be handled in btrfs using the same code. Without this, 32-bit {ch,ls}attr
fail.

Signed-off-by: Luke Dashjr <luke-jr+git@utopios.org>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/ctree.h
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c

index 6661ad8b4088d5eba027a7b6bd72f482977dcfd2..7c9a9c026e2188c644b71cc9d23bf02ee2d4346d 100644 (file)
@@ -4089,6 +4089,7 @@ void btrfs_test_inode_set_ops(struct inode *inode);
 
 /* ioctl.c */
 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 void btrfs_update_iflags(struct inode *inode);
 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
 int btrfs_is_empty_uuid(u8 *uuid);
index 5d956b869e03dd6bf4f0ef7585e96550f050ad24..187fa7b9bae726a1235ba7274c16ae513bc5e00f 100644 (file)
@@ -2931,7 +2931,7 @@ const struct file_operations btrfs_file_operations = {
        .fallocate      = btrfs_fallocate,
        .unlocked_ioctl = btrfs_ioctl,
 #ifdef CONFIG_COMPAT
-       .compat_ioctl   = btrfs_ioctl,
+       .compat_ioctl   = btrfs_compat_ioctl,
 #endif
        .copy_file_range = btrfs_copy_file_range,
        .clone_file_range = btrfs_clone_file_range,
index f407e487c6879a8e3349fd0a1380f685837f5f32..0db33cb4a2ace9394e03ca97491f781d2cbb97c1 100644 (file)
@@ -10088,7 +10088,7 @@ static const struct file_operations btrfs_dir_file_operations = {
        .iterate        = btrfs_real_readdir,
        .unlocked_ioctl = btrfs_ioctl,
 #ifdef CONFIG_COMPAT
-       .compat_ioctl   = btrfs_ioctl,
+       .compat_ioctl   = btrfs_compat_ioctl,
 #endif
        .release        = btrfs_release_file,
        .fsync          = btrfs_sync_file,
index e3791f2684890f7b24a82786d51c206dd9f08a6a..ea21e588a8392da923bab64656826abed1a675d4 100644 (file)
@@ -5555,3 +5555,24 @@ long btrfs_ioctl(struct file *file, unsigned int
 
        return -ENOTTY;
 }
+
+#ifdef CONFIG_COMPAT
+long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       switch (cmd) {
+       case FS_IOC32_GETFLAGS:
+               cmd = FS_IOC_GETFLAGS;
+               break;
+       case FS_IOC32_SETFLAGS:
+               cmd = FS_IOC_SETFLAGS;
+               break;
+       case FS_IOC32_GETVERSION:
+               cmd = FS_IOC_GETVERSION;
+               break;
+       default:
+               return -ENOIOCTLCMD;
+       }
+
+       return btrfs_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
+}
+#endif