]> 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)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 22 Aug 2016 21:37:52 +0000 (22:37 +0100)
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>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/btrfs/ctree.h
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c

index efb0b8953fa57bc67fef58f66335e3b05d4c7688..796f1d2374fffdfb60946da7dec25351c8387f39 100644 (file)
@@ -3876,6 +3876,7 @@ extern const struct dentry_operations btrfs_dentry_operations;
 
 /* 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 8d60cf5195788967d8d7dba750e0f68c27b34dfe..085a90d0d2e4b787b312cc497026eb180dd757ff 100644 (file)
@@ -2739,7 +2739,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
 };
 
index 17472ba1615c7ff08a89a3193dcb9a436fbac117..a09ec5e7f3e2221b89b9170ab3ba555b3e2fcf81 100644 (file)
@@ -9102,7 +9102,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 d0733078e5c5925ea93db22b5815bc1ccc729ff4..b69285f0593b57bf6b2d737b9efca1461f20d928 100644 (file)
@@ -5520,3 +5520,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