Bug 192237 - Floating point error when creating partition on dm device
Summary: Floating point error when creating partition on dm device
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: parted
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: David Cantrell
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-05-18 15:12 UTC by Mark McLoughlin
Modified: 2007-11-30 22:11 UTC (History)
5 users (show)

Fixed In Version: parted-1.7.1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-09-26 06:49:02 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Mark McLoughlin 2006-05-18 15:12:16 UTC
In recent kernels, dm allows user-space to set the geometry of a device:

http://www.redhat.com/archives/dm-devel/2006-February/msg00137.html

So, by default, HDIO_GETGEO now returns zero for the geometry paramters rather
than returning -ENOTTY

This causes a divide-by-zero in linux.c:_device_probe_geometry():

  if (!ioctl (arch_specific->fd, HDIO_GETGEO, &geometry)) {
      dev->hw_geom.sectors = geometry.sectors;
      dev->hw_geom.heads = geometry.heads;
      dev->hw_geom.cylinders
            = dev->length / (dev->hw_geom.heads
                             * dev->hw_geom.sectors)
                          / (dev->sector_size / PED_SECTOR_SIZE);

Suggest either checking for zero return on these paramets and falling back to
the default values.

(Of course, you could probably also argue that dm should continue returning
-ENOTTY when the geometry hasn't been set. cc-ing agk)

To reproduce:

$> dd if=/dev/zero of=/tmp/t.img bs=1M count=0 seek=4096
0+0 records in
0+0 records out
0 bytes (0 B) copied, 7.3e-05 seconds, 0.0 kB/s
$> losetup /dev/loop0 /tmp/t.img
$> echo "0 8388608 linear /dev/loop0 0" | dmsetup create foo
$> parted /dev/mapper/foo mklabel msdos
Floating point exception

Comment 1 Alasdair Kergon 2006-09-13 18:37:09 UTC
man 4 sd says:

If the geometry information is not available, zero will be returned for all of
the parameters.


Comment 2 David Cantrell 2006-09-13 18:43:50 UTC
Just tried the reproducer listed above on rawhide.  I don't get the floating
point exception.

I have parted-1.7.1-15.fc6 in rawhide right now.

Can the reporter please try rawhide to verify the problem is gone (or still exists)?

Thanks.

Comment 3 Mark McLoughlin 2006-09-26 06:49:02 UTC
Right, it's fixed now:

        if (!ioctl (arch_specific->fd, HDIO_GETGEO, &geometry)
                        && geometry.sectors && geometry.heads) {



Note You need to log in before you can comment on or make changes to this bug.