parted crashes on lvm, on a dasd drive

Bug #1541510 reported by Dimitri John Ledkov
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Debian
Fix Released
Unknown
debian-installer (Ubuntu)
Fix Released
Undecided
Unassigned
parted (Ubuntu)
Fix Released
High
Unassigned

Bug Description

xnox@devac03:~$ lsdasd
Bus-ID Status Name Device Type BlkSz Size Blocks
==============================================================================
0.0.0200 active dasda 94:0 ECKD 4096 7042MB 1802880
0.0.0201 active dasdb 94:4 ECKD 4096 42258MB 10818180
0.0.0202 active dasdc 94:8 ECKD 4096 42258MB 10818180

# pvcreate /dev/dasdc1
  allocation/use_blkid_wiping=1 configuration setting is set while LVM is not compiled with blkid wiping support.
  Falling back to native LVM signature detection.
  Physical volume "/dev/dasdc1" successfully created

# vgcreate new /dev/dasdc1
  Volume group "new" successfully created

# lvcreate -L 2000M new
  allocation/use_blkid_wiping=1 configuration setting is set while LVM is not compiled with blkid wiping support.
  Falling back to native LVM signature detection.
  Logical volume "lvol0" created.

# gdb parted
(gdb) run /dev/mapper/new-lvol0
Starting program: /sbin/parted /dev/mapper/new-lvol0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/s390x-linux-gnu/libthread_db.so.1".
GNU Parted 3.2
Using /dev/mapper/new-lvol0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print

Program received signal SIGFPE, Arithmetic exception.
vtoc_set_freespace (f4=<optimized out>, f5=0x2aa0003c0e0, f7=<optimized out>, ch=<optimized out>,
    verbose=0, start=2, stop=4294967295, cyl=60101, trk=0) at ../../../libparted/labels/vtoc.c:1321
1321 ../../../libparted/labels/vtoc.c: No such file or directory.
(gdb) bt
#0 vtoc_set_freespace (f4=<optimized out>, f5=0x2aa0003c0e0, f7=<optimized out>,
    ch=<optimized out>, verbose=0, start=2, stop=4294967295, cyl=60101, trk=0)
    at ../../../libparted/labels/vtoc.c:1321
#1 0x000003fffdea1b20 in fdasd_check_volume (anc=0x3ffffffeee0, fd=<optimized out>)
    at ../../../libparted/labels/fdasd.c:886
#2 0x000003fffde9f6c2 in dasd_probe (dev=0x2aa00030fb0) at ../../../libparted/labels/dasd.c:226
#3 0x000003fffde8fb5e in ped_disk_probe (dev=0x2aa00030fb0) at ../../libparted/disk.c:157
#4 0x000003fffde9240c in ped_disk_new (dev=0x2aa00030fb0) at ../../libparted/disk.c:190
#5 0x000002aa00008c28 in do_print (dev=0x3fffffff428, diskp=0x3fffffff430)
    at ../../parted/parted.c:1067
#6 0x000002aa0000e810 in interactive_mode (dev=0x3fffffff428, disk=0x3fffffff430,
    cmd_list=<optimized out>) at ../../parted/ui.c:1593
#7 0x000002aa00007020 in main (argc=0, argv=0x3fffffff688) at ../../parted/parted.c:2297

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

 vtoc_set_freespace (f4=<optimized out>, f5=0x2aa0003c0e0, f7=<optimized out>,
    ch=<optimized out>, verbose=0, start=2, stop=4294967295, cyl=60101, trk=0)
    at ../../../libparted/labels/vtoc.c:1321

vtoc_set_freespace is called with trk=0, yet

1321: y = (u_int16_t) ((stop - start + 1) / trk);

tries to divide by zero.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

$ sudo ./test_lvm_drive
Heads 0
Secotrs 0
Cylinders 1023
Start 4397693661968

Revision history for this message
Colin Watson (cjwatson) wrote :

Maybe try bailing out of fdasd_set_geometry if HDIO_GETGEO returns 0 for sectors or heads; then the probing logic should move onto other labels, since this isn't really a DASD anyway.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

fdasd_check_volume calls vtoc_set_freespace with anc->geo.heads argument

fdasd_check_volume is called from dasd_probe

which before calling fdasd_check_volume called fdasd_get_geometry, which did iocl call, and filled the geometry with:

Heads 0
Secotrs 0
Cylinders 1023
Start 4397693661968

thus in vtoc_set_freespace we end up with division by zero and blow up

Changed in parted (Ubuntu):
assignee: nobody → Viktor Mihajlovski (mihajlov)
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

not sure, if dasdfmt would be also affected

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

$ uname -a
Linux devac03 4.4.0-2-generic #16-Ubuntu SMP Thu Jan 28 15:44:18 UTC 2016 s390x s390x s390x GNU/Linux

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

<cjwatson> I think you're going to see the same thing upstream
<cjwatson> The more generic _device_probe_geometry has explicit checks for getting non-zero sectors and heads back from HDIO_GETGEO
<cjwatson> and if it doesn't get them it uses defaults
<cjwatson> But fdasd_get_geometry doesn't have quite the same checks around its use of HDIO_GETGEO
<cjwatson> You ought to compare with the relevant kernel code, but my suspicion is that you don't get a sensible geometry back for an LV
<cjwatson> This is all inside dasd_probe, and an LV isn't really a DASD
<cjwatson> So one thing I'd try is making that situation be an error from fdasd_get_geometry and seeing if that behaves reasonably
<cjwatson> Something like http://paste.ubuntu.com/14868640/ maybe?
<cjwatson> Ew is that file really tabstop=4? Anyway
<cjwatson> xnox: ^- suggestions above for you BTW

Revision history for this message
Dimitri John Ledkov (xnox) wrote :
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

$ sudo parted /dev/mapper/new-lvol0
GNU Parted 3.2
Using /dev/mapper/new-lvol0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
BUG: trk is zero in vtoc_set_freespace call
BUG: trk is zero in vtoc_set_freespace call
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/new-lvol0: 2097MB
Sector size (logical/physical): 4096B/4096B
Partition Table: dasd
Disk Flags:

Number Start End Size File system Flags

with my patch to avoid SIGFPE in said call. However, I think something more sensible should be done there instead.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in s390-tools (Ubuntu):
status: New → Confirmed
tags: added: patch
Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2016-02-03 16:34 EDT-------
---Problem Description---
parted crashes on lvm, on a dasd drive

---Steps to Reproduce---
Bus-ID Status Name Device Type BlkSz Size Blocks
0.0.0200 active dasda 94:0 ECKD 4096 7042MB 1802880
0.0.0201 active dasdb 94:4 ECKD 4096 42258MB 10818180
0.0.0202 active dasdc 94:8 ECKD 4096 42258MB 10818180

tags: added: architecture-s39064 bugnameltc-136561 severity-high targetmilestone-inin---
Revision history for this message
Phillip Susi (psusi) wrote :

Why does it even try to activate the dasd code on a logical volume? It shouldn't be doing that at all as it should not know or care that the logical volume is built on top of a dasd disk. Unless... iirc there was some special ioctl that dasd disks have and that is how parted knows it is dasd... maybe device-mapper is passing this ioctl down and so parted really is talking to a dasd disk?

Revision history for this message
Viktor Mihajlovski (mihajlov-deactivatedaccount) wrote :

The parted code is iterating all the label types and consequently is probing for DASD. The weird thing is that on one hand the DASD ioctl is passed down to the physical volume (and I mean weird: what would have happened if the logical volume was realised by extents on both DASD and SCSI disks?) and on the other hand silently igores the HDIO_GETGEO.(which I can understand). Currently trying out a patch similar to the one posted by Colin.

Revision history for this message
Viktor Mihajlovski (mihajlov-deactivatedaccount) wrote :

You might want to try out this patch which worked for me. I was able to partition the logical volume on top of a DASD PV. If this solves the problem in the installer I can follow up with upstream.

Revision history for this message
Viktor Mihajlovski (mihajlov-deactivatedaccount) wrote :

Regarding comment #6: this doesn't affect s390-tools. Please remove the connection to the package.

Changed in s390-tools (Ubuntu):
assignee: nobody → Dimitri John Ledkov (xnox)
affects: s390-tools (Ubuntu) → debian-installer (Ubuntu)
Changed in debian-installer (Ubuntu):
assignee: Dimitri John Ledkov (xnox) → nobody
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package parted - 3.2-14ubuntu1

---------------
parted (3.2-14ubuntu1) xenial; urgency=medium

  * Apply patch from mihajlov to ignore geometry-less DASD that is picked
    up under otherwise innocent LVM volumes. LP: #1541510

 -- Dimitri John Ledkov <email address hidden> Thu, 04 Feb 2016 16:18:31 +0000

Changed in parted (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2016-02-05 08:33 EDT-------
I have run the installer with the libparted2-udeb-3.2-14ubuntu1 as follows:

First Run:
Empty DASD, no PV signatures.
Manual partitioning.
Make a single partition (/dev/dasda1) holding a PV.
Configure LVM: add VG, make new LV.
Use LV as / (ext4)
Continue installation (zipl fails, but this was probably to be expected)

Second Run:
DASD from first run: one partition, 1 PV, 1 VG, 1 LV.
Configure LVM: remove LV, VG.
Change partitioning:
/dev/dasda1 (1G): use as /boot (ext4)
/dev/dasda2 (21G): use as PV
Configure LVM: add VG, make to new LVs (root: 18G, swap: 3G)
Use LV root as / (ext4)
Use LV swap as swap
Continue installation and reboot

System comes up fine and I can run parted against all partitions and LVs with no problems.

Revision history for this message
Phillip Susi (psusi) wrote :

Then I'd say that the bug is actually in the kernel: it should *not* be passing down the dasd partition manipulation ioctls. Patching parted to ignore it based on GETGEO works around the problem and stops parted from crashing, but ultimately, you do not want to allow any partitioning tool to mess about with the dasd disk label through the lens of device-mapper.

Changed in debian:
status: Unknown → Confirmed
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Confirming that lvm installation works as expected, closing the d-i task.

I would have hoped that lvm without stand-alone /boot would have worked.

Let me open a new bug report to re-validate that.

Changed in debian-installer (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Dimitri John Ledkov (xnox) wrote :
bugproxy (bugproxy)
tags: added: targetmilestone-inin1604
removed: targetmilestone-inin---
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2016-02-10 11:01 EDT-------
I successfully installed Ubuntu with LVM with a recent Ubuntu release. The bug can be closed as fixed.

Changed in debian:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.