Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a362249 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by David Sterba
Browse files

btrfs: fix btrfs_compat_ioctl failures on non-compat ioctls



Commit 4c63c245 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: 4c63c245 ("btrfs: bugfix: handle FS_IOC32_{GETFLAGS,SETFLAGS,GETVERSION} in btrfs_ioctl")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 57b59ed2
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -5665,6 +5665,10 @@ long btrfs_ioctl(struct file *file, unsigned int
#ifdef CONFIG_COMPAT
#ifdef CONFIG_COMPAT
long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
{
	/*
	 * These all access 32-bit values anyway so no further
	 * handling is necessary.
	 */
	switch (cmd) {
	switch (cmd) {
	case FS_IOC32_GETFLAGS:
	case FS_IOC32_GETFLAGS:
		cmd = FS_IOC_GETFLAGS;
		cmd = FS_IOC_GETFLAGS;
@@ -5675,8 +5679,6 @@ long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
	case FS_IOC32_GETVERSION:
	case FS_IOC32_GETVERSION:
		cmd = FS_IOC_GETVERSION;
		cmd = FS_IOC_GETVERSION;
		break;
		break;
	default:
		return -ENOIOCTLCMD;
	}
	}


	return btrfs_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
	return btrfs_ioctl(file, cmd, (unsigned long) compat_ptr(arg));