Commit 76c072b48e39e9291fbf02d6c912cf27d65e093d

Authored by Milan Broz
Committed by Alasdair G Kergon
1 parent 27238b2bea

dm ioctl: move compat code

Move compat_ioctl handling into dm-ioctl.c.

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>

Showing 3 changed files with 15 additions and 68 deletions Side-by-side Diff

drivers/md/dm-ioctl.c
... ... @@ -15,6 +15,7 @@
15 15 #include <linux/slab.h>
16 16 #include <linux/dm-ioctl.h>
17 17 #include <linux/hdreg.h>
  18 +#include <linux/compat.h>
18 19  
19 20 #include <asm/uaccess.h>
20 21  
21 22  
... ... @@ -1350,10 +1351,10 @@
1350 1351 {
1351 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 1355 return -EFAULT;
1355 1356  
1356   - if (tmp.data_size < sizeof(tmp))
  1357 + if (tmp.data_size < (sizeof(tmp) - sizeof(tmp.data)))
1357 1358 return -EINVAL;
1358 1359  
1359 1360 dmi = vmalloc(tmp.data_size);
1360 1361  
... ... @@ -1474,8 +1475,18 @@
1474 1475 return (long)ctl_ioctl(command, (struct dm_ioctl __user *)u);
1475 1476 }
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 +
1477 1487 static const struct file_operations _ctl_fops = {
1478 1488 .unlocked_ioctl = dm_ctl_ioctl,
  1489 + .compat_ioctl = dm_compat_ctl_ioctl,
1479 1490 .owner = THIS_MODULE,
1480 1491 };
1481 1492  
... ... @@ -78,7 +78,6 @@
78 78 #include <linux/mii.h>
79 79 #include <linux/if_bonding.h>
80 80 #include <linux/watchdog.h>
81   -#include <linux/dm-ioctl.h>
82 81  
83 82 #include <linux/soundcard.h>
84 83 #include <linux/lp.h>
... ... @@ -1993,39 +1992,6 @@
1993 1992 COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
1994 1993 COMPATIBLE_IOCTL(GET_BITMAP_FILE)
1995 1994 ULONG_IOCTL(SET_BITMAP_FILE)
1996   -/* DM */
1997   -COMPATIBLE_IOCTL(DM_VERSION_32)
1998   -COMPATIBLE_IOCTL(DM_REMOVE_ALL_32)
1999   -COMPATIBLE_IOCTL(DM_LIST_DEVICES_32)
2000   -COMPATIBLE_IOCTL(DM_DEV_CREATE_32)
2001   -COMPATIBLE_IOCTL(DM_DEV_REMOVE_32)
2002   -COMPATIBLE_IOCTL(DM_DEV_RENAME_32)
2003   -COMPATIBLE_IOCTL(DM_DEV_SUSPEND_32)
2004   -COMPATIBLE_IOCTL(DM_DEV_STATUS_32)
2005   -COMPATIBLE_IOCTL(DM_DEV_WAIT_32)
2006   -COMPATIBLE_IOCTL(DM_TABLE_LOAD_32)
2007   -COMPATIBLE_IOCTL(DM_TABLE_CLEAR_32)
2008   -COMPATIBLE_IOCTL(DM_TABLE_DEPS_32)
2009   -COMPATIBLE_IOCTL(DM_TABLE_STATUS_32)
2010   -COMPATIBLE_IOCTL(DM_LIST_VERSIONS_32)
2011   -COMPATIBLE_IOCTL(DM_TARGET_MSG_32)
2012   -COMPATIBLE_IOCTL(DM_DEV_SET_GEOMETRY_32)
2013   -COMPATIBLE_IOCTL(DM_VERSION)
2014   -COMPATIBLE_IOCTL(DM_REMOVE_ALL)
2015   -COMPATIBLE_IOCTL(DM_LIST_DEVICES)
2016   -COMPATIBLE_IOCTL(DM_DEV_CREATE)
2017   -COMPATIBLE_IOCTL(DM_DEV_REMOVE)
2018   -COMPATIBLE_IOCTL(DM_DEV_RENAME)
2019   -COMPATIBLE_IOCTL(DM_DEV_SUSPEND)
2020   -COMPATIBLE_IOCTL(DM_DEV_STATUS)
2021   -COMPATIBLE_IOCTL(DM_DEV_WAIT)
2022   -COMPATIBLE_IOCTL(DM_TABLE_LOAD)
2023   -COMPATIBLE_IOCTL(DM_TABLE_CLEAR)
2024   -COMPATIBLE_IOCTL(DM_TABLE_DEPS)
2025   -COMPATIBLE_IOCTL(DM_TABLE_STATUS)
2026   -COMPATIBLE_IOCTL(DM_LIST_VERSIONS)
2027   -COMPATIBLE_IOCTL(DM_TARGET_MSG)
2028   -COMPATIBLE_IOCTL(DM_DEV_SET_GEOMETRY)
2029 1995 /* Big K */
2030 1996 COMPATIBLE_IOCTL(PIO_FONT)
2031 1997 COMPATIBLE_IOCTL(GIO_FONT)
include/linux/dm-ioctl.h
... ... @@ -232,36 +232,6 @@
232 232 DM_DEV_SET_GEOMETRY_CMD
233 233 };
234 234  
235   -/*
236   - * The dm_ioctl struct passed into the ioctl is just the header
237   - * on a larger chunk of memory. On x86-64 and other
238   - * architectures the dm-ioctl struct will be padded to an 8 byte
239   - * boundary so the size will be different, which would change the
240   - * ioctl code - yes I really messed up. This hack forces these
241   - * architectures to have the correct ioctl code.
242   - */
243   -#ifdef CONFIG_COMPAT
244   -typedef char ioctl_struct[308];
245   -#define DM_VERSION_32 _IOWR(DM_IOCTL, DM_VERSION_CMD, ioctl_struct)
246   -#define DM_REMOVE_ALL_32 _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, ioctl_struct)
247   -#define DM_LIST_DEVICES_32 _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, ioctl_struct)
248   -
249   -#define DM_DEV_CREATE_32 _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, ioctl_struct)
250   -#define DM_DEV_REMOVE_32 _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, ioctl_struct)
251   -#define DM_DEV_RENAME_32 _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, ioctl_struct)
252   -#define DM_DEV_SUSPEND_32 _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, ioctl_struct)
253   -#define DM_DEV_STATUS_32 _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, ioctl_struct)
254   -#define DM_DEV_WAIT_32 _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, ioctl_struct)
255   -
256   -#define DM_TABLE_LOAD_32 _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, ioctl_struct)
257   -#define DM_TABLE_CLEAR_32 _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, ioctl_struct)
258   -#define DM_TABLE_DEPS_32 _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, ioctl_struct)
259   -#define DM_TABLE_STATUS_32 _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, ioctl_struct)
260   -#define DM_LIST_VERSIONS_32 _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, ioctl_struct)
261   -#define DM_TARGET_MSG_32 _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, ioctl_struct)
262   -#define DM_DEV_SET_GEOMETRY_32 _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, ioctl_struct)
263   -#endif
264   -
265 235 #define DM_IOCTL 0xfd
266 236  
267 237 #define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
268 238  
... ... @@ -286,9 +256,9 @@
286 256 #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
287 257  
288 258 #define DM_VERSION_MAJOR 4
289   -#define DM_VERSION_MINOR 12
  259 +#define DM_VERSION_MINOR 13
290 260 #define DM_VERSION_PATCHLEVEL 0
291   -#define DM_VERSION_EXTRA "-ioctl (2007-10-02)"
  261 +#define DM_VERSION_EXTRA "-ioctl (2007-10-18)"
292 262  
293 263 /* Status bits */
294 264 #define DM_READONLY_FLAG (1 << 0) /* In/Out */