Re: blockdev.c: getsize(): signed args, error checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Karel Zak <kzak@xxxxxxxxxx> wrote:
> On Fri, Oct 19, 2007 at 01:39:38PM +0200, Stefan Krah wrote:
> > in getsize() the BLKGETSIZE and BLKGETSIZE64 ioctls are called
> > with signed args, see the patch below.
> 
>  Ah.. I've already fixed this bug in other place in blockdev
>  (--getsize, --getsize64).
> 
>  I see same signed args in fdisk/disksize.c :-( We need to cleanup this
>  code, remove all getsize() versions and create libs/blkdevsize.c
>  (see TODO).

It would be great to have an implementation that is guaranteed to work
with older kernels. The getsize() of e2fsprogs for example doesn't trust
BLKGETSIZE64 for kernels < 2.6.


> > Since the EFBIG change in getsize() sz might contain garbage, so there
> > should be additional error checks, something like (yes, this is ugly):
> 
>  I think you needn't extra check, you can zeroize "sz" when the first
>  ioctl() returns an error.

I can't see that. If the second ioctl() also returns with an error, getsize()
will return success and a sector count of sz, which then would be 0.


It just struck me that if you use `blockdev --getsize64 ...`, the
BLKGETSIZE64 ioctl() is trusted without the additional (b == 0 || b == sz)
check (workaround?).



Stefan Krah


-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux