compat_hdio_ioctl: get rid of set_fs()
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 27 Jun 2017 19:51:38 +0000 (15:51 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 29 Jun 2017 22:17:52 +0000 (18:17 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
block/compat_ioctl.c

index 696e0cdd2df1c307c7ffa9cc829f096e2d2d035e..38554c2ea38adc28f0835b35f65cdb2c94451656 100644 (file)
@@ -79,19 +79,16 @@ static int compat_hdio_getgeo(struct gendisk *disk, struct block_device *bdev,
 static int compat_hdio_ioctl(struct block_device *bdev, fmode_t mode,
                unsigned int cmd, unsigned long arg)
 {
-       mm_segment_t old_fs = get_fs();
-       unsigned long kval;
-       unsigned int __user *uvp;
+       unsigned long *__user p;
        int error;
 
-       set_fs(KERNEL_DS);
+       p = compat_alloc_user_space(sizeof(unsigned long));
        error = __blkdev_driver_ioctl(bdev, mode,
-                               cmd, (unsigned long)(&kval));
-       set_fs(old_fs);
-
+                               cmd, (unsigned long)p);
        if (error == 0) {
-               uvp = compat_ptr(arg);
-               if (put_user(kval, uvp))
+               unsigned int __user *uvp = compat_ptr(arg);
+               unsigned long v;
+               if (get_user(v, p) || put_user(v, uvp))
                        error = -EFAULT;
        }
        return error;