diff options
author | Jeff Mahoney <jeffm@suse.com> | 2017-02-06 19:39:09 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-02-14 18:25:40 -0500 |
commit | 93fb043478b8d81cfa0d2399223bbf96bdb138e8 (patch) | |
tree | 8cf2a676be07e0a3dd39e970e74550ebcff41dd1 | |
parent | 76a9ac048b4876849b6e95fa4b20cca949f2bf0a (diff) |
btrfs: fix btrfs_compat_ioctl failures on non-compat ioctls
commit 2a362249187a8d0f6d942d6e1d763d150a296f47 upstream.
Commit 4c63c2454ef incorrectly assumed that returning -ENOIOCTLCMD would
cause the native ioctl to be called. The ->compat_ioctl callback is
expected to handle all ioctls, not just compat variants. As a result,
when using 32-bit userspace on 64-bit kernels, everything except those
three ioctls would return -ENOTTY.
Fixes: 4c63c2454ef ("btrfs: bugfix: handle FS_IOC32_{GETFLAGS,SETFLAGS,GETVERSION} in btrfs_ioctl")
Signed-off-by: Jeff Mahoney <jeffm@suse.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>
-rw-r--r-- | fs/btrfs/ioctl.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 7acbd2cf6192..1782804f6c26 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -5648,6 +5648,10 @@ long btrfs_ioctl(struct file *file, unsigned int | |||
5648 | #ifdef CONFIG_COMPAT | 5648 | #ifdef CONFIG_COMPAT |
5649 | long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 5649 | long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
5650 | { | 5650 | { |
5651 | /* | ||
5652 | * These all access 32-bit values anyway so no further | ||
5653 | * handling is necessary. | ||
5654 | */ | ||
5651 | switch (cmd) { | 5655 | switch (cmd) { |
5652 | case FS_IOC32_GETFLAGS: | 5656 | case FS_IOC32_GETFLAGS: |
5653 | cmd = FS_IOC_GETFLAGS; | 5657 | cmd = FS_IOC_GETFLAGS; |
@@ -5658,8 +5662,6 @@ long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
5658 | case FS_IOC32_GETVERSION: | 5662 | case FS_IOC32_GETVERSION: |
5659 | cmd = FS_IOC_GETVERSION; | 5663 | cmd = FS_IOC_GETVERSION; |
5660 | break; | 5664 | break; |
5661 | default: | ||
5662 | return -ENOIOCTLCMD; | ||
5663 | } | 5665 | } |
5664 | 5666 | ||
5665 | return btrfs_ioctl(file, cmd, (unsigned long) compat_ptr(arg)); | 5667 | return btrfs_ioctl(file, cmd, (unsigned long) compat_ptr(arg)); |