Re: [stable] [2.6.24 PATCH 02/25] dm io:ctl use constant struct size

2007-11-13 Thread Greg KH
On Mon, Oct 15, 2007 at 09:34:09AM +0200, Arnd Bergmann wrote:
> On Monday 15 October 2007, Alasdair G Kergon wrote:
> > The underlying ABI is not changing, I hope - the trailing padding in the
> > struct should not affect the processing of the data by dm, and I see no
> > reason to continue maintaining the fiction that the 32-bit and 64-bit
> > ioctls are in some way incompatible with each other when they aren't
> > AFAIK.
> 
> It's a corner case of some sort, as DM uses ioctl numbers differently
> from most subsystems by splitting to code from the size argument
> during processing. Your change is certainly not an _incompatible_
> change to the ABI, but 32 bit binaries compiled against the new
> headers will use different ioctl numbers from those built against
> older headers.
> 
> This may break other code that expects a specific number, even
> if your handler does not care. The old compat code handles both
> variants (no variable size arguments), but /usr/bin/strace may have
> encoded only one set of numbers AFAICT.
> 
> > And yes, a follow-up patch can clean up our use of the compatibility
> > mechanism, going a little bit further than the patch you attached, I
> > hope.
> 
> Ok, sounds good. I don't think it's the kind of patch that should go
> into stable backports though.

Ok, I've not added this patch (2/25) to the queue at all.  If this is
incorrect, please let me know.

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [stable] [2.6.24 PATCH 02/25] dm io:ctl use constant struct size

2007-11-13 Thread Greg KH
On Mon, Oct 15, 2007 at 09:34:09AM +0200, Arnd Bergmann wrote:
 On Monday 15 October 2007, Alasdair G Kergon wrote:
  The underlying ABI is not changing, I hope - the trailing padding in the
  struct should not affect the processing of the data by dm, and I see no
  reason to continue maintaining the fiction that the 32-bit and 64-bit
  ioctls are in some way incompatible with each other when they aren't
  AFAIK.
 
 It's a corner case of some sort, as DM uses ioctl numbers differently
 from most subsystems by splitting to code from the size argument
 during processing. Your change is certainly not an _incompatible_
 change to the ABI, but 32 bit binaries compiled against the new
 headers will use different ioctl numbers from those built against
 older headers.
 
 This may break other code that expects a specific number, even
 if your handler does not care. The old compat code handles both
 variants (no variable size arguments), but /usr/bin/strace may have
 encoded only one set of numbers AFAICT.
 
  And yes, a follow-up patch can clean up our use of the compatibility
  mechanism, going a little bit further than the patch you attached, I
  hope.
 
 Ok, sounds good. I don't think it's the kind of patch that should go
 into stable backports though.

Ok, I've not added this patch (2/25) to the queue at all.  If this is
incorrect, please let me know.

thanks,

greg k-h
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [2.6.24 PATCH 02/25] dm io:ctl use constant struct size

2007-10-15 Thread Arnd Bergmann
On Monday 15 October 2007, Alasdair G Kergon wrote:
> The underlying ABI is not changing, I hope - the trailing padding in the
> struct should not affect the processing of the data by dm, and I see no
> reason to continue maintaining the fiction that the 32-bit and 64-bit
> ioctls are in some way incompatible with each other when they aren't
> AFAIK.

It's a corner case of some sort, as DM uses ioctl numbers differently
from most subsystems by splitting to code from the size argument
during processing. Your change is certainly not an _incompatible_
change to the ABI, but 32 bit binaries compiled against the new
headers will use different ioctl numbers from those built against
older headers.

This may break other code that expects a specific number, even
if your handler does not care. The old compat code handles both
variants (no variable size arguments), but /usr/bin/strace may have
encoded only one set of numbers AFAICT.

> And yes, a follow-up patch can clean up our use of the compatibility
> mechanism, going a little bit further than the patch you attached, I
> hope.

Ok, sounds good. I don't think it's the kind of patch that should go
into stable backports though.

Arnd <><
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [2.6.24 PATCH 02/25] dm io:ctl use constant struct size

2007-10-15 Thread Arnd Bergmann
On Monday 15 October 2007, Alasdair G Kergon wrote:
 The underlying ABI is not changing, I hope - the trailing padding in the
 struct should not affect the processing of the data by dm, and I see no
 reason to continue maintaining the fiction that the 32-bit and 64-bit
 ioctls are in some way incompatible with each other when they aren't
 AFAIK.

It's a corner case of some sort, as DM uses ioctl numbers differently
from most subsystems by splitting to code from the size argument
during processing. Your change is certainly not an _incompatible_
change to the ABI, but 32 bit binaries compiled against the new
headers will use different ioctl numbers from those built against
older headers.

This may break other code that expects a specific number, even
if your handler does not care. The old compat code handles both
variants (no variable size arguments), but /usr/bin/strace may have
encoded only one set of numbers AFAICT.

 And yes, a follow-up patch can clean up our use of the compatibility
 mechanism, going a little bit further than the patch you attached, I
 hope.

Ok, sounds good. I don't think it's the kind of patch that should go
into stable backports though.

Arnd 
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [2.6.24 PATCH 02/25] dm io:ctl use constant struct size

2007-10-14 Thread Alasdair G Kergon
On Sat, Oct 13, 2007 at 12:16:29AM +0200, Arnd Bergmann wrote:
> This change seems rather bogus, you're changing the ABI just to work
> around a bug in the compat_ioctl layer. Why not just do the compat
> code the right way, like the patch below?

The underlying ABI is not changing, I hope - the trailing padding in the
struct should not affect the processing of the data by dm, and I see no
reason to continue maintaining the fiction that the 32-bit and 64-bit
ioctls are in some way incompatible with each other when they aren't
AFAIK.

And yes, a follow-up patch can clean up our use of the compatibility
mechanism, going a little bit further than the patch you attached, I
hope.

Alasdair
-- 
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [2.6.24 PATCH 02/25] dm io:ctl use constant struct size

2007-10-14 Thread Alasdair G Kergon
On Sat, Oct 13, 2007 at 12:16:29AM +0200, Arnd Bergmann wrote:
 This change seems rather bogus, you're changing the ABI just to work
 around a bug in the compat_ioctl layer. Why not just do the compat
 code the right way, like the patch below?

The underlying ABI is not changing, I hope - the trailing padding in the
struct should not affect the processing of the data by dm, and I see no
reason to continue maintaining the fiction that the 32-bit and 64-bit
ioctls are in some way incompatible with each other when they aren't
AFAIK.

And yes, a follow-up patch can clean up our use of the compatibility
mechanism, going a little bit further than the patch you attached, I
hope.

Alasdair
-- 
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [2.6.24 PATCH 02/25] dm io:ctl use constant struct size

2007-10-12 Thread Arnd Bergmann
On Friday 12 October 2007, Alasdair G Kergon wrote:
> Make size of dm_ioctl struct always 312 bytes on all supported
> architectures.
> 
> This change retains compatibility with already-compiled code because
> it uses an embedded offset to locate the payload that follows the
> structure.
> 
> On 64-bit architectures there is no change at all; on 32-bit
> we are increasing the size of dm-ioctl from 308 to 312 bytes.
> 
> Currently with 32-bit userspace / 64-bit kernel on x86_64
> some ioctls (including rename, message) are incorrectly rejected
> by the comparison against 'param + 1'.  This breaks userspace
> lvrename and multipath 'fail_if_no_path' changes, for example.
> 
> (BTW Device-mapper uses its own versioning and ignores the ioctl
> size bits.  Only the generic ioctl compat code on mixed arches
> checks them, and that will continue to accept both sizes for now,
> but we intend to list 308 as deprecated and eventually remove it.)
> 
> Signed-off-by: Milan Broz <[EMAIL PROTECTED]>
> Signed-off-by: Alasdair G Kergon <[EMAIL PROTECTED]>
> Cc: Guido Guenther <[EMAIL PROTECTED]>
> Cc: Kevin Corry <[EMAIL PROTECTED]>
> Cc: [EMAIL PROTECTED]
> 

This change seems rather bogus, you're changing the ABI just to work
around a bug in the compat_ioctl layer. Why not just do the compat
code the right way, like the patch below?

Arnd <><

---
dm: move compat_ioctl handling to dm-ioctl.c

Device mapper ioctl numbers use a variable size field

Signed-off-by: Arnd Bergmann <[EMAIL PROTECTED]>
---
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index b441d82..a662279 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -700,7 +700,7 @@ static int dev_rename(struct dm_ioctl *param, size_t 
param_size)
int r;
char *new_name = (char *) param + param->data_start;
 
-   if (new_name < (char *) (param + 1) ||
+   if (new_name < (char *)param + param->data_size ||
invalid_str(new_name, (void *) param + param_size)) {
DMWARN("Invalid new logical volume name supplied.");
return -EINVAL;
@@ -726,7 +726,7 @@ static int dev_set_geometry(struct dm_ioctl *param, size_t 
param_size)
if (!md)
return -ENXIO;
 
-   if (geostr < (char *) (param + 1) ||
+   if (geostr < (char *)param + param->data_size ||
invalid_str(geostr, (void *) param + param_size)) {
DMWARN("Invalid geometry supplied.");
goto out;
@@ -1233,7 +1233,7 @@ static int target_message(struct dm_ioctl *param, size_t 
param_size)
if (r)
goto out;
 
-   if (tmsg < (struct dm_target_msg *) (param + 1) ||
+   if (tmsg < (struct dm_target_msg *) ((char *)param + param->data_size) 
||
invalid_str(tmsg->message, (void *) param + param_size)) {
DMWARN("Invalid target message parameters.");
r = -EINVAL;
@@ -1348,11 +1348,11 @@ static void free_params(struct dm_ioctl *param)
vfree(param);
 }
 
-static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param)
+static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param, 
uint ulen)
 {
struct dm_ioctl tmp, *dmi;
 
-   if (copy_from_user(, user, sizeof(tmp)))
+   if (copy_from_user(, user, ulen))
return -EFAULT;
 
if (tmp.data_size < sizeof(tmp))
@@ -1399,13 +1399,11 @@ static int validate_params(uint cmd, struct dm_ioctl 
*param)
return 0;
 }
 
-static int ctl_ioctl(struct inode *inode, struct file *file,
-uint command, ulong u)
+static int ctl_ioctl(uint command, struct dm_ioctl __user *user, uint ulen)
 {
int r = 0;
unsigned int cmd;
struct dm_ioctl *param;
-   struct dm_ioctl __user *user = (struct dm_ioctl __user *) u;
ioctl_fn fn = NULL;
size_t param_size;
 
@@ -1447,7 +1445,7 @@ static int ctl_ioctl(struct inode *inode, struct file 
*file,
/*
 * Copy the parameters into kernel space.
 */
-   r = copy_params(user, );
+   r = copy_params(user, , ulen);
 
current->flags &= ~PF_MEMALLOC;
 
@@ -1459,7 +1457,7 @@ static int ctl_ioctl(struct inode *inode, struct file 
*file,
goto out;
 
param_size = param->data_size;
-   param->data_size = sizeof(*param);
+   param->data_size = ulen;
r = fn(param, param_size);
 
/*
@@ -1473,8 +1471,64 @@ static int ctl_ioctl(struct inode *inode, struct file 
*file,
return r;
 }
 
+static int ctl_ioctl(struct inode *inode, struct file *file,
+uint command, ulong u)
+{
+   return ctl_do_ioctl(command, (void __user *)u, sizeof (struct 
dm_ioctl));
+}
+
+#ifdef CONFIG_COMPAT
+struct compat_dm_ioctl {
+   /*
+* The version number is made up of three parts:
+* major - no backward or forward compatibility,
+* minor - only backwards compatible,
+* patch - both 

[2.6.24 PATCH 02/25] dm io:ctl use constant struct size

2007-10-12 Thread Alasdair G Kergon
From: Milan Broz <[EMAIL PROTECTED]>

Make size of dm_ioctl struct always 312 bytes on all supported
architectures.

This change retains compatibility with already-compiled code because
it uses an embedded offset to locate the payload that follows the
structure.

On 64-bit architectures there is no change at all; on 32-bit
we are increasing the size of dm-ioctl from 308 to 312 bytes.

Currently with 32-bit userspace / 64-bit kernel on x86_64
some ioctls (including rename, message) are incorrectly rejected
by the comparison against 'param + 1'.  This breaks userspace
lvrename and multipath 'fail_if_no_path' changes, for example.

(BTW Device-mapper uses its own versioning and ignores the ioctl
size bits.  Only the generic ioctl compat code on mixed arches
checks them, and that will continue to accept both sizes for now,
but we intend to list 308 as deprecated and eventually remove it.)

Signed-off-by: Milan Broz <[EMAIL PROTECTED]>
Signed-off-by: Alasdair G Kergon <[EMAIL PROTECTED]>
Cc: Guido Guenther <[EMAIL PROTECTED]>
Cc: Kevin Corry <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]

---
 drivers/md/dm-ioctl.c|6 +++---
 include/linux/dm-ioctl.h |5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

Index: linux-2.6.23/drivers/md/dm-ioctl.c
===
--- linux-2.6.23.orig/drivers/md/dm-ioctl.c 2007-10-12 13:15:21.0 
+0100
+++ linux-2.6.23/drivers/md/dm-ioctl.c  2007-10-12 13:15:29.0 +0100
@@ -700,7 +700,7 @@ static int dev_rename(struct dm_ioctl *p
int r;
char *new_name = (char *) param + param->data_start;
 
-   if (new_name < (char *) (param + 1) ||
+   if (new_name < (char *) param->data ||
invalid_str(new_name, (void *) param + param_size)) {
DMWARN("Invalid new logical volume name supplied.");
return -EINVAL;
@@ -726,7 +726,7 @@ static int dev_set_geometry(struct dm_io
if (!md)
return -ENXIO;
 
-   if (geostr < (char *) (param + 1) ||
+   if (geostr < (char *) param->data ||
invalid_str(geostr, (void *) param + param_size)) {
DMWARN("Invalid geometry supplied.");
goto out;
@@ -1233,7 +1233,7 @@ static int target_message(struct dm_ioct
if (r)
goto out;
 
-   if (tmsg < (struct dm_target_msg *) (param + 1) ||
+   if (tmsg < (struct dm_target_msg *) param->data ||
invalid_str(tmsg->message, (void *) param + param_size)) {
DMWARN("Invalid target message parameters.");
r = -EINVAL;
Index: linux-2.6.23/include/linux/dm-ioctl.h
===
--- linux-2.6.23.orig/include/linux/dm-ioctl.h  2007-10-12 13:15:21.0 
+0100
+++ linux-2.6.23/include/linux/dm-ioctl.h   2007-10-12 13:15:29.0 
+0100
@@ -131,6 +131,7 @@ struct dm_ioctl {
char name[DM_NAME_LEN]; /* device name */
char uuid[DM_UUID_LEN]; /* unique identifier for
 * the block device */
+   char data[7];   /* padding or data */
 };
 
 /*
@@ -285,9 +286,9 @@ typedef char ioctl_struct[308];
 #define DM_DEV_SET_GEOMETRY_IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct 
dm_ioctl)
 
 #define DM_VERSION_MAJOR   4
-#define DM_VERSION_MINOR   11
+#define DM_VERSION_MINOR   12
 #define DM_VERSION_PATCHLEVEL  0
-#define DM_VERSION_EXTRA   "-ioctl (2006-10-12)"
+#define DM_VERSION_EXTRA   "-ioctl (2007-10-02)"
 
 /* Status bits */
 #define DM_READONLY_FLAG   (1 << 0) /* In/Out */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[2.6.24 PATCH 02/25] dm io:ctl use constant struct size

2007-10-12 Thread Alasdair G Kergon
From: Milan Broz [EMAIL PROTECTED]

Make size of dm_ioctl struct always 312 bytes on all supported
architectures.

This change retains compatibility with already-compiled code because
it uses an embedded offset to locate the payload that follows the
structure.

On 64-bit architectures there is no change at all; on 32-bit
we are increasing the size of dm-ioctl from 308 to 312 bytes.

Currently with 32-bit userspace / 64-bit kernel on x86_64
some ioctls (including rename, message) are incorrectly rejected
by the comparison against 'param + 1'.  This breaks userspace
lvrename and multipath 'fail_if_no_path' changes, for example.

(BTW Device-mapper uses its own versioning and ignores the ioctl
size bits.  Only the generic ioctl compat code on mixed arches
checks them, and that will continue to accept both sizes for now,
but we intend to list 308 as deprecated and eventually remove it.)

Signed-off-by: Milan Broz [EMAIL PROTECTED]
Signed-off-by: Alasdair G Kergon [EMAIL PROTECTED]
Cc: Guido Guenther [EMAIL PROTECTED]
Cc: Kevin Corry [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]

---
 drivers/md/dm-ioctl.c|6 +++---
 include/linux/dm-ioctl.h |5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

Index: linux-2.6.23/drivers/md/dm-ioctl.c
===
--- linux-2.6.23.orig/drivers/md/dm-ioctl.c 2007-10-12 13:15:21.0 
+0100
+++ linux-2.6.23/drivers/md/dm-ioctl.c  2007-10-12 13:15:29.0 +0100
@@ -700,7 +700,7 @@ static int dev_rename(struct dm_ioctl *p
int r;
char *new_name = (char *) param + param-data_start;
 
-   if (new_name  (char *) (param + 1) ||
+   if (new_name  (char *) param-data ||
invalid_str(new_name, (void *) param + param_size)) {
DMWARN(Invalid new logical volume name supplied.);
return -EINVAL;
@@ -726,7 +726,7 @@ static int dev_set_geometry(struct dm_io
if (!md)
return -ENXIO;
 
-   if (geostr  (char *) (param + 1) ||
+   if (geostr  (char *) param-data ||
invalid_str(geostr, (void *) param + param_size)) {
DMWARN(Invalid geometry supplied.);
goto out;
@@ -1233,7 +1233,7 @@ static int target_message(struct dm_ioct
if (r)
goto out;
 
-   if (tmsg  (struct dm_target_msg *) (param + 1) ||
+   if (tmsg  (struct dm_target_msg *) param-data ||
invalid_str(tmsg-message, (void *) param + param_size)) {
DMWARN(Invalid target message parameters.);
r = -EINVAL;
Index: linux-2.6.23/include/linux/dm-ioctl.h
===
--- linux-2.6.23.orig/include/linux/dm-ioctl.h  2007-10-12 13:15:21.0 
+0100
+++ linux-2.6.23/include/linux/dm-ioctl.h   2007-10-12 13:15:29.0 
+0100
@@ -131,6 +131,7 @@ struct dm_ioctl {
char name[DM_NAME_LEN]; /* device name */
char uuid[DM_UUID_LEN]; /* unique identifier for
 * the block device */
+   char data[7];   /* padding or data */
 };
 
 /*
@@ -285,9 +286,9 @@ typedef char ioctl_struct[308];
 #define DM_DEV_SET_GEOMETRY_IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct 
dm_ioctl)
 
 #define DM_VERSION_MAJOR   4
-#define DM_VERSION_MINOR   11
+#define DM_VERSION_MINOR   12
 #define DM_VERSION_PATCHLEVEL  0
-#define DM_VERSION_EXTRA   -ioctl (2006-10-12)
+#define DM_VERSION_EXTRA   -ioctl (2007-10-02)
 
 /* Status bits */
 #define DM_READONLY_FLAG   (1  0) /* In/Out */
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [2.6.24 PATCH 02/25] dm io:ctl use constant struct size

2007-10-12 Thread Arnd Bergmann
On Friday 12 October 2007, Alasdair G Kergon wrote:
 Make size of dm_ioctl struct always 312 bytes on all supported
 architectures.
 
 This change retains compatibility with already-compiled code because
 it uses an embedded offset to locate the payload that follows the
 structure.
 
 On 64-bit architectures there is no change at all; on 32-bit
 we are increasing the size of dm-ioctl from 308 to 312 bytes.
 
 Currently with 32-bit userspace / 64-bit kernel on x86_64
 some ioctls (including rename, message) are incorrectly rejected
 by the comparison against 'param + 1'.  This breaks userspace
 lvrename and multipath 'fail_if_no_path' changes, for example.
 
 (BTW Device-mapper uses its own versioning and ignores the ioctl
 size bits.  Only the generic ioctl compat code on mixed arches
 checks them, and that will continue to accept both sizes for now,
 but we intend to list 308 as deprecated and eventually remove it.)
 
 Signed-off-by: Milan Broz [EMAIL PROTECTED]
 Signed-off-by: Alasdair G Kergon [EMAIL PROTECTED]
 Cc: Guido Guenther [EMAIL PROTECTED]
 Cc: Kevin Corry [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 

This change seems rather bogus, you're changing the ABI just to work
around a bug in the compat_ioctl layer. Why not just do the compat
code the right way, like the patch below?

Arnd 

---
dm: move compat_ioctl handling to dm-ioctl.c

Device mapper ioctl numbers use a variable size field

Signed-off-by: Arnd Bergmann [EMAIL PROTECTED]
---
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index b441d82..a662279 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -700,7 +700,7 @@ static int dev_rename(struct dm_ioctl *param, size_t 
param_size)
int r;
char *new_name = (char *) param + param-data_start;
 
-   if (new_name  (char *) (param + 1) ||
+   if (new_name  (char *)param + param-data_size ||
invalid_str(new_name, (void *) param + param_size)) {
DMWARN(Invalid new logical volume name supplied.);
return -EINVAL;
@@ -726,7 +726,7 @@ static int dev_set_geometry(struct dm_ioctl *param, size_t 
param_size)
if (!md)
return -ENXIO;
 
-   if (geostr  (char *) (param + 1) ||
+   if (geostr  (char *)param + param-data_size ||
invalid_str(geostr, (void *) param + param_size)) {
DMWARN(Invalid geometry supplied.);
goto out;
@@ -1233,7 +1233,7 @@ static int target_message(struct dm_ioctl *param, size_t 
param_size)
if (r)
goto out;
 
-   if (tmsg  (struct dm_target_msg *) (param + 1) ||
+   if (tmsg  (struct dm_target_msg *) ((char *)param + param-data_size) 
||
invalid_str(tmsg-message, (void *) param + param_size)) {
DMWARN(Invalid target message parameters.);
r = -EINVAL;
@@ -1348,11 +1348,11 @@ static void free_params(struct dm_ioctl *param)
vfree(param);
 }
 
-static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param)
+static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param, 
uint ulen)
 {
struct dm_ioctl tmp, *dmi;
 
-   if (copy_from_user(tmp, user, sizeof(tmp)))
+   if (copy_from_user(tmp, user, ulen))
return -EFAULT;
 
if (tmp.data_size  sizeof(tmp))
@@ -1399,13 +1399,11 @@ static int validate_params(uint cmd, struct dm_ioctl 
*param)
return 0;
 }
 
-static int ctl_ioctl(struct inode *inode, struct file *file,
-uint command, ulong u)
+static int ctl_ioctl(uint command, struct dm_ioctl __user *user, uint ulen)
 {
int r = 0;
unsigned int cmd;
struct dm_ioctl *param;
-   struct dm_ioctl __user *user = (struct dm_ioctl __user *) u;
ioctl_fn fn = NULL;
size_t param_size;
 
@@ -1447,7 +1445,7 @@ static int ctl_ioctl(struct inode *inode, struct file 
*file,
/*
 * Copy the parameters into kernel space.
 */
-   r = copy_params(user, param);
+   r = copy_params(user, param, ulen);
 
current-flags = ~PF_MEMALLOC;
 
@@ -1459,7 +1457,7 @@ static int ctl_ioctl(struct inode *inode, struct file 
*file,
goto out;
 
param_size = param-data_size;
-   param-data_size = sizeof(*param);
+   param-data_size = ulen;
r = fn(param, param_size);
 
/*
@@ -1473,8 +1471,64 @@ static int ctl_ioctl(struct inode *inode, struct file 
*file,
return r;
 }
 
+static int ctl_ioctl(struct inode *inode, struct file *file,
+uint command, ulong u)
+{
+   return ctl_do_ioctl(command, (void __user *)u, sizeof (struct 
dm_ioctl));
+}
+
+#ifdef CONFIG_COMPAT
+struct compat_dm_ioctl {
+   /*
+* The version number is made up of three parts:
+* major - no backward or forward compatibility,
+* minor - only backwards compatible,
+* patch - both backwards and forwards compatible.
+*
+