Skip to content

Commit 3013838

Browse files
author
Al Viro
committed
compat_hdio_ioctl: get rid of set_fs()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 229b53c commit 3013838

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

block/compat_ioctl.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,16 @@ static int compat_hdio_getgeo(struct gendisk *disk, struct block_device *bdev,
7979
static int compat_hdio_ioctl(struct block_device *bdev, fmode_t mode,
8080
unsigned int cmd, unsigned long arg)
8181
{
82-
mm_segment_t old_fs = get_fs();
83-
unsigned long kval;
84-
unsigned int __user *uvp;
82+
unsigned long *__user p;
8583
int error;
8684

87-
set_fs(KERNEL_DS);
85+
p = compat_alloc_user_space(sizeof(unsigned long));
8886
error = __blkdev_driver_ioctl(bdev, mode,
89-
cmd, (unsigned long)(&kval));
90-
set_fs(old_fs);
91-
87+
cmd, (unsigned long)p);
9288
if (error == 0) {
93-
uvp = compat_ptr(arg);
94-
if (put_user(kval, uvp))
89+
unsigned int __user *uvp = compat_ptr(arg);
90+
unsigned long v;
91+
if (get_user(v, p) || put_user(v, uvp))
9592
error = -EFAULT;
9693
}
9794
return error;

0 commit comments

Comments
 (0)