floppy: fix usercopy direction
authorJann Horn <jannh@google.com>
Tue, 26 Mar 2019 22:03:48 +0000 (23:03 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 9 Aug 2019 13:41:36 +0000 (07:41 -0600)
As sparse points out, these two copy_from_user() should actually be
copy_to_user().

Fixes: 229b53c9bf4e ("take floppy compat ioctls to sodding floppy.c")
Cc: stable@vger.kernel.org
Acked-by: Alexander Popov <alex.popov@linux.com>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/floppy.c

index 0469aceaa230778896d02dbde35e3270aa494992..485865fd0412e40d041e861506bb3ac11a3a91e3 100644 (file)
@@ -3780,7 +3780,7 @@ static int compat_getdrvprm(int drive,
        v.native_format = UDP->native_format;
        mutex_unlock(&floppy_mutex);
 
-       if (copy_from_user(arg, &v, sizeof(struct compat_floppy_drive_params)))
+       if (copy_to_user(arg, &v, sizeof(struct compat_floppy_drive_params)))
                return -EFAULT;
        return 0;
 }
@@ -3816,7 +3816,7 @@ static int compat_getdrvstat(int drive, bool poll,
        v.bufblocks = UDRS->bufblocks;
        mutex_unlock(&floppy_mutex);
 
-       if (copy_from_user(arg, &v, sizeof(struct compat_floppy_drive_struct)))
+       if (copy_to_user(arg, &v, sizeof(struct compat_floppy_drive_struct)))
                return -EFAULT;
        return 0;
 Eintr: