All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm.c
@ 2006-05-04  1:51 m9230
  0 siblings, 0 replies; 6+ messages in thread
From: m9230 @ 2006-05-04  1:51 UTC (permalink / raw)
  To: dm-devel

Hello, I found a problem in dm_blk_ioctl() in dm.c:

In dm.c, dm_blk_ioctl() is assigning a full unsigned 32 bits of device size 
to a signed 32 bit size.
This may cause BLKGETSIZE64 ioctl and BLKGETSIZE ioctl failed to get the 
device size when device size is larger than 1TB.

I am using device-mapper.1.01.05.

Changing "long size;" to "sector_t size;" might fix this up, it works for me.
For example:
error = ioctl(fd, BLKGETSIZE64, &size);
returns "size" in bytes.


--
Best Regards, Michael Yao

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] dm.c
@ 2006-05-04  2:51 m9230
  0 siblings, 0 replies; 6+ messages in thread
From: m9230 @ 2006-05-04  2:51 UTC (permalink / raw)
  To: dm-devel

Hello, I found a problem in dm_blk_ioctl() in dm.c:

In dm.c, dm_blk_ioctl() is assigning a full unsigned 32 bits of device size 
to a signed 32 bit size.
This may cause BLKGETSIZE64 ioctl and BLKGETSIZE ioctl failed to get the 
device size when device size is larger than 1TB.

I am using device-mapper.1.01.05.

Changing "long size;" to "sector_t size;" might fix this up, it works for me.
For example:
error = ioctl(fd, BLKGETSIZE64, &size);
returns "size" in bytes.


--
Best Regards, Michael Yao

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dm.c
       [not found] <20060504160048.CA34173C68@hormel.redhat.com>
@ 2006-05-05  7:35 ` m9230
  2006-05-05 13:45   ` Kevin Corry
  0 siblings, 1 reply; 6+ messages in thread
From: m9230 @ 2006-05-05  7:35 UTC (permalink / raw)
  To: dm-devel

Hi

I am sorry that I did not list the original source.
Thanks to Eric, this is the original source: 
http://oss.sgi.com/bugzilla/show_bug.cgi?id=646 


> Message: 1
> Date: Thu, 4 May 2006 10:51:39 +0800
> From: "m9230" <m9230@cn.ee.ccu.edu.tw>
> Subject: [dm-devel] [PATCH] dm.c
> To: dm-devel@redhat.com
> Message-ID: <20060504025139.M49417@cn.ee.ccu.edu.tw>
> Content-Type: text/plain;	charset=big5
> 
> Hello, I found a problem in dm_blk_ioctl() in dm.c:
> 
> In dm.c, dm_blk_ioctl() is assigning a full unsigned 32 bits of 
> device size to a signed 32 bit size. This may cause BLKGETSIZE64 
> ioctl and BLKGETSIZE ioctl failed to get the device size when device 
> size is larger than 1TB.
> 
> I am using device-mapper.1.01.05.
> 
> Changing "long size;" to "sector_t size;" might fix this up, it 
> works for me. For example: error = ioctl(fd, BLKGETSIZE64, &size); 
> returns "size" in bytes.
> 
> --
> Best Regards, Michael Yao

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dm.c
  2006-05-05  7:35 ` [PATCH] dm.c m9230
@ 2006-05-05 13:45   ` Kevin Corry
  2006-05-05 13:56     ` Kevin Corry
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Corry @ 2006-05-05 13:45 UTC (permalink / raw)
  To: dm-devel; +Cc: Eric Sandeen, m9230

On Fri May 5 2006 2:35 am, m9230 wrote:
> I am sorry that I did not list the original source.
> Thanks to Eric, this is the original source:
> http://oss.sgi.com/bugzilla/show_bug.cgi?id=646
>
> > Hello, I found a problem in dm_blk_ioctl() in dm.c:
> >
> > In dm.c, dm_blk_ioctl() is assigning a full unsigned 32 bits of
> > device size to a signed 32 bit size. This may cause BLKGETSIZE64
> > ioctl and BLKGETSIZE ioctl failed to get the device size when device
> > size is larger than 1TB.
> >
> > I am using device-mapper.1.01.05.
> >
> > Changing "long size;" to "sector_t size;" might fix this up, it
> > works for me. For example: error = ioctl(fd, BLKGETSIZE64, &size);
> > returns "size" in bytes.

I haven't seen an actual patch yet for this bug, so here's one with the 
suggested fix (against 2.4.31 + device-mapper-1.02.05).

-- 
Kevin Corry
kevcorry@us.ibm.com
http://www.ibm.com/linux/
http://evms.sourceforge.net/



In dm_blk_ioctl(), change 'size' to a sector_t so we can correctly return
the size of devices between 1 and 2 TB.

Fix suggested by Eric Sandeen <sandeen@sgi.com>
http://oss.sgi.com/bugzilla/show_bug.cgi?id=646

Signed-Off-By: Kevin Corry <kevcorry@us.ibm.com>

Index: 2.4.31/drivers/md/dm.c
===================================================================
--- 2.4.31.orig/drivers/md/dm.c
+++ 2.4.31/drivers/md/dm.c
@@ -456,7 +456,7 @@ static int dm_blk_ioctl(struct inode *in
 			unsigned int command, unsigned long a)
 {
 	kdev_t dev = inode->i_rdev;
-	long size;
+	sector_t size;
 
 	switch (command) {
 	case BLKROSET:
@@ -476,7 +476,7 @@ static int dm_blk_ioctl(struct inode *in
 
 	case BLKGETSIZE:
 		size = volume_size(dev);
-		if (copy_to_user((void *) a, &size, sizeof(long)))
+		if (put_user((unsigned long) size, (unsigned long *) a))
 			return -EFAULT;
 		break;
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dm.c
  2006-05-05 13:45   ` Kevin Corry
@ 2006-05-05 13:56     ` Kevin Corry
  2006-05-05 14:09       ` Eric Sandeen
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Corry @ 2006-05-05 13:56 UTC (permalink / raw)
  To: dm-devel; +Cc: Eric Sandeen, m9230

On Fri May 5 2006 8:45 am, Kevin Corry wrote:
> I haven't seen an actual patch yet for this bug, so here's one with the
> suggested fix (against 2.4.31 + device-mapper-1.02.05).

And just in case it's easier for the DM guys, here's the same fix as a patch 
against linux-2.4.28-pre4-devmapper-ioctl.patch from device-mapper-1.02.05.

-- 
Kevin Corry
kevcorry@us.ibm.com
http://www.ibm.com/linux/
http://evms.sourceforge.net/



In dm_blk_ioctl(), change 'size' to a sector_t so we can correctly return
the size of devices between 1 and 2 TB.

Fix suggested by Eric Sandeen <sandeen@sgi.com>
http://oss.sgi.com/bugzilla/show_bug.cgi?id=646

Signed-Off-By: Kevin Corry <kevcorry@us.ibm.com>

Index: device-mapper.1.02.05/patches/linux-2.4.28-pre4-devmapper-ioctl.patch
===================================================================
--- device-mapper.1.02.05.orig/patches/linux-2.4.28-pre4-devmapper-ioctl.patch
+++ device-mapper.1.02.05/patches/linux-2.4.28-pre4-devmapper-ioctl.patch
@@ -7823,7 +7823,7 @@
 +			unsigned int command, unsigned long a)
 +{
 +	kdev_t dev = inode->i_rdev;
-+	long size;
++	sector_t size;
 +
 +	switch (command) {
 +	case BLKROSET:
@@ -7843,7 +7843,7 @@
 +
 +	case BLKGETSIZE:
 +		size = volume_size(dev);
-+		if (copy_to_user((void *) a, &size, sizeof(long)))
++		if (put_user((unsigned long) size, (unsigned long *) a))
 +			return -EFAULT;
 +		break;
 +

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dm.c
  2006-05-05 13:56     ` Kevin Corry
@ 2006-05-05 14:09       ` Eric Sandeen
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Sandeen @ 2006-05-05 14:09 UTC (permalink / raw)
  To: Kevin Corry; +Cc: dm-devel, m9230

Kevin Corry wrote:
> On Fri May 5 2006 8:45 am, Kevin Corry wrote:
> 
>>I haven't seen an actual patch yet for this bug, so here's one with the
>>suggested fix (against 2.4.31 + device-mapper-1.02.05).
> 
> 
> And just in case it's easier for the DM guys, here's the same fix as a patch 
> against linux-2.4.28-pre4-devmapper-ioctl.patch from device-mapper-1.02.05.
> 


Kevin, looks right to me.

There's maybe a bit of extra casting left in the BLKGETSIZE64: case, but harmless.

And thanks for the attribution, I hope I didn't come across as -too- surly on
that topic. ;-)

And now xfs+evms users should be happy!

-Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-05-05 14:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20060504160048.CA34173C68@hormel.redhat.com>
2006-05-05  7:35 ` [PATCH] dm.c m9230
2006-05-05 13:45   ` Kevin Corry
2006-05-05 13:56     ` Kevin Corry
2006-05-05 14:09       ` Eric Sandeen
2006-05-04  2:51 m9230
  -- strict thread matches above, loose matches on Subject: below --
2006-05-04  1:51 m9230

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.