diff options
Diffstat (limited to 'drivers/md/dm-ioctl.c')
-rw-r--r-- | drivers/md/dm-ioctl.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 9627fa0f9470..b262c0042de3 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/dm-ioctl.h> | 16 | #include <linux/dm-ioctl.h> |
17 | #include <linux/hdreg.h> | 17 | #include <linux/hdreg.h> |
18 | #include <linux/compat.h> | ||
18 | 19 | ||
19 | #include <asm/uaccess.h> | 20 | #include <asm/uaccess.h> |
20 | 21 | ||
@@ -702,7 +703,7 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size) | |||
702 | int r; | 703 | int r; |
703 | char *new_name = (char *) param + param->data_start; | 704 | char *new_name = (char *) param + param->data_start; |
704 | 705 | ||
705 | if (new_name < (char *) param->data || | 706 | if (new_name < param->data || |
706 | invalid_str(new_name, (void *) param + param_size)) { | 707 | invalid_str(new_name, (void *) param + param_size)) { |
707 | DMWARN("Invalid new logical volume name supplied."); | 708 | DMWARN("Invalid new logical volume name supplied."); |
708 | return -EINVAL; | 709 | return -EINVAL; |
@@ -728,7 +729,7 @@ static int dev_set_geometry(struct dm_ioctl *param, size_t param_size) | |||
728 | if (!md) | 729 | if (!md) |
729 | return -ENXIO; | 730 | return -ENXIO; |
730 | 731 | ||
731 | if (geostr < (char *) param->data || | 732 | if (geostr < param->data || |
732 | invalid_str(geostr, (void *) param + param_size)) { | 733 | invalid_str(geostr, (void *) param + param_size)) { |
733 | DMWARN("Invalid geometry supplied."); | 734 | DMWARN("Invalid geometry supplied."); |
734 | goto out; | 735 | goto out; |
@@ -1350,10 +1351,10 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param) | |||
1350 | { | 1351 | { |
1351 | struct dm_ioctl tmp, *dmi; | 1352 | struct dm_ioctl tmp, *dmi; |
1352 | 1353 | ||
1353 | if (copy_from_user(&tmp, user, sizeof(tmp))) | 1354 | if (copy_from_user(&tmp, user, sizeof(tmp) - sizeof(tmp.data))) |
1354 | return -EFAULT; | 1355 | return -EFAULT; |
1355 | 1356 | ||
1356 | if (tmp.data_size < sizeof(tmp)) | 1357 | if (tmp.data_size < (sizeof(tmp) - sizeof(tmp.data))) |
1357 | return -EINVAL; | 1358 | return -EINVAL; |
1358 | 1359 | ||
1359 | dmi = vmalloc(tmp.data_size); | 1360 | dmi = vmalloc(tmp.data_size); |
@@ -1397,13 +1398,11 @@ static int validate_params(uint cmd, struct dm_ioctl *param) | |||
1397 | return 0; | 1398 | return 0; |
1398 | } | 1399 | } |
1399 | 1400 | ||
1400 | static int ctl_ioctl(struct inode *inode, struct file *file, | 1401 | static int ctl_ioctl(uint command, struct dm_ioctl __user *user) |
1401 | uint command, ulong u) | ||
1402 | { | 1402 | { |
1403 | int r = 0; | 1403 | int r = 0; |
1404 | unsigned int cmd; | 1404 | unsigned int cmd; |
1405 | struct dm_ioctl *param; | 1405 | struct dm_ioctl *uninitialized_var(param); |
1406 | struct dm_ioctl __user *user = (struct dm_ioctl __user *) u; | ||
1407 | ioctl_fn fn = NULL; | 1406 | ioctl_fn fn = NULL; |
1408 | size_t param_size; | 1407 | size_t param_size; |
1409 | 1408 | ||
@@ -1471,8 +1470,23 @@ static int ctl_ioctl(struct inode *inode, struct file *file, | |||
1471 | return r; | 1470 | return r; |
1472 | } | 1471 | } |
1473 | 1472 | ||
1473 | static long dm_ctl_ioctl(struct file *file, uint command, ulong u) | ||
1474 | { | ||
1475 | return (long)ctl_ioctl(command, (struct dm_ioctl __user *)u); | ||
1476 | } | ||
1477 | |||
1478 | #ifdef CONFIG_COMPAT | ||
1479 | static long dm_compat_ctl_ioctl(struct file *file, uint command, ulong u) | ||
1480 | { | ||
1481 | return (long)dm_ctl_ioctl(file, command, (ulong) compat_ptr(u)); | ||
1482 | } | ||
1483 | #else | ||
1484 | #define dm_compat_ctl_ioctl NULL | ||
1485 | #endif | ||
1486 | |||
1474 | static const struct file_operations _ctl_fops = { | 1487 | static const struct file_operations _ctl_fops = { |
1475 | .ioctl = ctl_ioctl, | 1488 | .unlocked_ioctl = dm_ctl_ioctl, |
1489 | .compat_ioctl = dm_compat_ctl_ioctl, | ||
1476 | .owner = THIS_MODULE, | 1490 | .owner = THIS_MODULE, |
1477 | }; | 1491 | }; |
1478 | 1492 | ||