* dm-ioctl on amd64 with 32bit userspace
@ 2007-09-17 16:57 Guido Guenther
2007-09-20 0:26 ` Andrew Morton
2007-09-20 15:32 ` Alasdair G Kergon
0 siblings, 2 replies; 7+ messages in thread
From: Guido Guenther @ 2007-09-17 16:57 UTC (permalink / raw)
To: Alasdair G Kergon; +Cc: Andrew Morton, dm-devel
Hi,
using something like:
dmsetup message <mpath> 0 fail_if_no_path
on a 32 bit dmsetup with a amd64 kernel currently fails with:
"Invalid target message parameters."
since the structure padding is 8 bytes and so we're looking at a 4 byte
to high address in target_message() - this also affects dev_rename() and
dev_set_geometry(). The attached patch works around the problem but
doesn't look like a proper fix. But since all the 32bit to 64bit ioctl
conversion in device mapper seems a bit strange, I'm not sure where to
fix this properly.
The bad thing about this is that multipath failover after a trespas on
such a system won't work (among other things). This at least has been
broken since 2.6.18 (I doubt it ever worked) and is still broken in
2.6.23-rc6-git7. With this patch, failover after a trespas and device
renaming works as expected.
Cheers,
-- Guido
Signed-off-by: Guido Guenther <agx@sigxcpu.org>
--- aa-amd64-smp/drivers/md/dm-ioctl.c 2007-09-17 14:51:10.000000000 +0000
+++ linux-2.6.22/drivers/md/dm-ioctl.c 2007-07-08 23:32:17.000000000 +0000
@@ -700,7 +700,7 @@
int r;
char *new_name = (char *) param + param->data_start;
- if (new_name < (char *) (param + 1) ||
+ if (new_name < (char *) ((void*)(param + 1) - 4) ||
invalid_str(new_name, (void *) param + param_size)) {
DMWARN("Invalid new logical volume name supplied.");
return -EINVAL;
@@ -726,7 +726,7 @@
if (!md)
return -ENXIO;
- if (geostr < (char *) (param + 1) ||
+ if (geostr < (char *) ((void *)(param + 1) - 4) ||
invalid_str(geostr, (void *) param + param_size)) {
DMWARN("Invalid geometry supplied.");
goto out;
@@ -1233,7 +1233,7 @@
if (r)
goto out;
- if (tmsg < (struct dm_target_msg *) (param + 1) ||
+ if (tmsg < (struct dm_target_msg *) ((void*)(param + 1) - 4) ||
invalid_str(tmsg->message, (void *) param + param_size)) {
DMWARN("Invalid target message parameters.");
r = -EINVAL;
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: dm-ioctl on amd64 with 32bit userspace
2007-09-17 16:57 dm-ioctl on amd64 with 32bit userspace Guido Guenther
@ 2007-09-20 0:26 ` Andrew Morton
2007-09-20 1:24 ` Alasdair G Kergon
2007-09-20 15:32 ` Alasdair G Kergon
1 sibling, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2007-09-20 0:26 UTC (permalink / raw)
To: Guido Guenther; +Cc: dm-devel, Alasdair G Kergon
On Mon, 17 Sep 2007 18:57:26 +0200
Guido Guenther <agx@sigxcpu.org> wrote:
> using something like:
>
> dmsetup message <mpath> 0 fail_if_no_path
>
> on a 32 bit dmsetup with a amd64 kernel currently fails with:
> "Invalid target message parameters."
>
> since the structure padding is 8 bytes and so we're looking at a 4 byte
> to high address in target_message() - this also affects dev_rename() and
> dev_set_geometry(). The attached patch works around the problem but
> doesn't look like a proper fix. But since all the 32bit to 64bit ioctl
> conversion in device mapper seems a bit strange, I'm not sure where to
> fix this properly.
>
> The bad thing about this is that multipath failover after a trespas on
> such a system won't work (among other things). This at least has been
> broken since 2.6.18 (I doubt it ever worked) and is still broken in
> 2.6.23-rc6-git7. With this patch, failover after a trespas and device
> renaming works as expected.
I don't understand why people aren't running around with their hair on fire
over this bug. Is everyone running 64-bit dmsetup, or what?
This looks like 2.6.22 and 2.6.23 material to me. Alasdair?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: dm-ioctl on amd64 with 32bit userspace
2007-09-20 0:26 ` Andrew Morton
@ 2007-09-20 1:24 ` Alasdair G Kergon
2007-09-20 7:07 ` Guido Guenther
0 siblings, 1 reply; 7+ messages in thread
From: Alasdair G Kergon @ 2007-09-20 1:24 UTC (permalink / raw)
To: Andrew Morton, Guido Guenther, dm-devel
On Wed, Sep 19, 2007 at 05:26:50PM -0700, Andrew Morton wrote:
> I don't understand why people aren't running around with their hair on fire
> over this bug. Is everyone running 64-bit dmsetup, or what?
1) There probably aren't many users in a mixed 32/64 environment;
2) The operations triggering the problem are fairly uncommon.
It's still a surprise nobody noticed this before (with lvrename) as it looks
like this has always been broken.
This particular patch looks inadequate though - fixes it for some people
but breaks it for others? Other parts of this code call alignment
functions and store offsets explicitly and probably something similar
should be happening here - with userspace libdevmapper changes too.
Let me consider the alternatives and their consequences.
> This looks like 2.6.22 and 2.6.23 material to me. Alasdair?
When we have a complete fix, yes.
Alasdair
--
agk@redhat.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: dm-ioctl on amd64 with 32bit userspace
2007-09-20 1:24 ` Alasdair G Kergon
@ 2007-09-20 7:07 ` Guido Guenther
0 siblings, 0 replies; 7+ messages in thread
From: Guido Guenther @ 2007-09-20 7:07 UTC (permalink / raw)
To: Andrew Morton, dm-devel
Hi,
On Thu, Sep 20, 2007 at 02:24:48AM +0100, Alasdair G Kergon wrote:
> On Wed, Sep 19, 2007 at 05:26:50PM -0700, Andrew Morton wrote:
> > I don't understand why people aren't running around with their hair on fire
> > over this bug. Is everyone running 64-bit dmsetup, or what?
>
> 1) There probably aren't many users in a mixed 32/64 environment;
> 2) The operations triggering the problem are fairly uncommon.
>
> It's still a surprise nobody noticed this before (with lvrename) as it looks
> like this has always been broken.
>
> This particular patch looks inadequate though - fixes it for some people
> but breaks it for others? Other parts of this code call alignment
Well at least it shouldn't break things for others, it just makes the
comparision a bit less strict - I agree that the code doesn't look nice
though.
Cheers,
-- Guido
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: dm-ioctl on amd64 with 32bit userspace
2007-09-17 16:57 dm-ioctl on amd64 with 32bit userspace Guido Guenther
2007-09-20 0:26 ` Andrew Morton
@ 2007-09-20 15:32 ` Alasdair G Kergon
2007-09-20 18:46 ` Guido Guenther
1 sibling, 1 reply; 7+ messages in thread
From: Alasdair G Kergon @ 2007-09-20 15:32 UTC (permalink / raw)
To: Guido Guenther; +Cc: Andrew Morton, dm-devel
On Mon, Sep 17, 2007 at 06:57:26PM +0200, Guido Guenther wrote:
> - if (new_name < (char *) (param + 1) ||
> + if (new_name < (char *) ((void*)(param + 1) - 4) ||
Does this (untested) also work for you?
+ if (new_name < (char *) (align_ptr(param + 1) - 4) ||
I think that's slightly better as it should leave the 32-bit
case unchanged.
One day, we'll fix all this properly by making the structure size in the
interface architecture-independent as it should have been in the first
place...
[http://www.kernel.org/pub/linux/kernel/people/agk/patches/2.6/editing/dm-ioctl-fix-compat-bounds-test.patch
but wait for it to resync]
Alasdair
--
agk@redhat.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: dm-ioctl on amd64 with 32bit userspace
2007-09-20 15:32 ` Alasdair G Kergon
@ 2007-09-20 18:46 ` Guido Guenther
[not found] ` <20070929132754.GA19089@bogon.ms20.nix>
0 siblings, 1 reply; 7+ messages in thread
From: Guido Guenther @ 2007-09-20 18:46 UTC (permalink / raw)
To: Andrew Morton, dm-devel
Hi Alasdair,
On Thu, Sep 20, 2007 at 04:32:10PM +0100, Alasdair G Kergon wrote:
> Does this (untested) also work for you?
>
> + if (new_name < (char *) (align_ptr(param + 1) - 4) ||
>
Yes this seems to work, I used:
Signed-off-by: Guido Guenther <agx@sigxcpu.org>
--- aa-amd64-smp/drivers/md/dm-ioctl.c 2007-09-17 14:51:10.000000000 +0000
+++ linux-2.6.22/drivers/md/dm-ioctl.c 2007-07-08 23:32:17.000000000 +0000
@@ -700,7 +700,7 @@
int r;
char *new_name = (char *) param + param->data_start;
- if (new_name < (char *) (param + 1) ||
+ if (new_name < (char *) (align_ptr(param + 1) - 4) ||
invalid_str(new_name, (void *) param + param_size)) {
DMWARN("Invalid new logical volume name supplied.");
return -EINVAL;
@@ -726,7 +726,7 @@
if (!md)
return -ENXIO;
- if (geostr < (char *) (param + 1) ||
+ if (geostr < (char *) (align_ptr(param + 1) - 4) ||
invalid_str(geostr, (void *) param + param_size)) {
DMWARN("Invalid geometry supplied.");
goto out;
@@ -1233,7 +1233,7 @@
if (r)
goto out;
- if (tmsg < (struct dm_target_msg *) (param + 1) ||
+ if (tmsg < (struct dm_target_msg *) (align_ptr(param + 1) - 4) ||
invalid_str(tmsg->message, (void *) param + param_size)) {
DMWARN("Invalid target message parameters.");
r = -EINVAL;
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-10-04 17:28 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-17 16:57 dm-ioctl on amd64 with 32bit userspace Guido Guenther
2007-09-20 0:26 ` Andrew Morton
2007-09-20 1:24 ` Alasdair G Kergon
2007-09-20 7:07 ` Guido Guenther
2007-09-20 15:32 ` Alasdair G Kergon
2007-09-20 18:46 ` Guido Guenther
[not found] ` <20070929132754.GA19089@bogon.ms20.nix>
[not found] ` <20071002010519.GB18444@agk.fab.redhat.com>
[not found] ` <20071002071647.GA11183@bogon.ms20.nix>
2007-10-04 17:28 ` Alasdair G Kergon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.