Bug 463878 - [5.3] mkdumprd Not Robust Enough
[5.3] mkdumprd Not Robust Enough
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kexec-tools (Show other bugs)
5.3
All Linux
medium Severity medium
: rc
: ---
Assigned To: Neil Horman
Martin Jenner
:
: 467483 468114 (view as bug list)
Depends On:
Blocks: 468087
  Show dependency treegraph
 
Reported: 2008-09-24 23:29 EDT by CAI Qian
Modified: 2010-10-23 00:46 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 600611 (view as bug list)
Environment:
Last Closed: 2009-01-20 15:59:59 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
patch to properly quote delimit LABELS (736 bytes, patch)
2008-09-25 15:14 EDT, Neil Horman
no flags Details | Diff
new version of patch (2.71 KB, patch)
2008-09-26 14:14 EDT, Neil Horman
no flags Details | Diff

  None (edit)
Description CAI Qian 2008-09-24 23:29:15 EDT
Description of problem:
mkdumprd is unable to copy with various of seems valid Kdump targets. The first one is a disk label which includes white spaces,

# /sbin/e2label /dev/mapper/VolGroup00-LogVol00 "KDUMP TEST"
Then, add the following line to kdump.conf
  ext3 LABEL="KDUMP TEST"
or
  ext3 "LABEL=KDUMP TEST"
or
  ext3 LABEL=KDUMP\ TEST

As the result, Kdump failed to start,
# service kdump start
Detected change(s) the following file(s):
  
  /etc/kdump.conf
Rebuilding /boot/efi/efi/redhat/initrd-2.6.18-116.el5kdump.img
error: quote mismatch for LABEL=KDUMP

usage: find [-type type] [path [-name file]]
/sbin/mkdumprd: line 1716: test: LABEL=KDUMP: binary operator expected
/etc/kdump.conf: Need a location for ext3
Failed to run mkdumprd
Starting kdump:[FAILED]

The other problem is two similar configurations behaved totally different,

ext3 /dev/mapper/VolGroup00-LogVol00

ext3 "/dev/mapper/VolGroup00-LogVol00"

The former is working as expected, but the later never works. It hung forever in Kdump Kernel here,

Waiting for required block device discovery
Waiting for sda...Found
Waiting for "mapper/VolGroup-LogVol00"...

From its initramfs, the content of /etc/critical_disks is the as the following,

sda
"mapper/VolGroup-LogVol00"

From the mkdumprd command traces, the problem is here,

-+ handlelvordev '"/dev/mapper/VolGroup00-LogVol00"'
-++ lvs --noheadings -o vg_name '"/dev/mapper/VolGroup00-LogVol00"'
-+ local vg=
-+ '[' -z '' ']'
-+++ echo '"/dev/mapper/VolGroup00-LogVol00"'
-+++ sed -e 's#^/dev/mapper/\([^-]*\)-\(.*\)$#/dev/\1/\2#'
-++ lvs --noheadings -o vg_name '"/dev/mapper/VolGroup00-LogVol00"'
-+ vg=
-+ '[' -n '' ']'
-+ findstoragedriver '"/dev/mapper/VolGroup00-LogVol00"'

Looks like "lvs" failed to find the correct VG name. If I run the command manually, I got,

# lvs --noheadings -o vg_name '"/dev/mapper/VolGroup00-LogVol00"'
  ""/dev/mapper/VolGroup00-LogVol00"": Invalid path for Logical Volume

Version-Release number of selected component (if applicable):
kexec-tools-1.102pre-40.el5

How reproducible:
always
Comment 1 CAI Qian 2008-09-25 00:57:19 EDT
Actually, the second issue is a regression against RHEL 5.2 introduced by the critical_disks changes. Therefore, previous working Kdump configuration files are not going to work correctly in RHEL 5.3.
Comment 2 Neil Horman 2008-09-25 15:14:23 EDT
Created attachment 317719 [details]
patch to properly quote delimit LABELS

you shouldn't ever need to quote delimit something without spaces in the config file.  As for the label with spaces, I'm not sure this will fix all the problems, but if you could, please give this patch a test and let me know the results.  Thanks!
Comment 3 CAI Qian 2008-09-26 02:20:59 EDT
I am afraid it won't work for me.

First test,
- config file:
ext3 LABEL="KDUMP TEST"

- start Kdump:
No kdump initial ramdisk found.[WARNING]^M
Rebuilding /boot/efi/efi/redhat/initrd-2.6.18-116.el5kdump.img
Usage: findfs LABEL=<label>|UUID=<uuid>
Starting kdump:[  OK  ]

- mkdumprd snip:
+ USING_METHOD=filesystem
+ echo 'LABEL="KDUMP' 'TEST"'
+ egrep -q '^(LABEL|UUID)='
++ findfs 'LABEL="KDUMP' 'TEST"'
Usage: findfs LABEL=<label>|UUID=<uuid>
+ config_val=
+ handlelvordev

- run Sysrq-C:
...
Scanning logical volumes
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup00" using metadata type lvm2
Activating logical volumes
  2 logical volume(s) in volume group "VolGroup00" now active
hwclock: Could not access RTC: No such file or directory
Saving to the local filesystem LABEL=KDUMP TEST
BusyBox v1.2.0 (2008.01.04-12:33+0000) multi-call binary

No help available.

BusyBox v1.2.0 (2008.01.04-12:33+0000) multi-call binary

No help available.

mount: Cannot read /etc/fstab: No such file or directory
umount: Couldn't umount /mnt: Invalid argument
[: 0: unknown operand
Attempting to enter user-space to capture vmcore
Creating root device.
Checking root filesystem.
fsck 1.38 (30-Jun-2005)
...

- init from initramfs snip:
...
echo Saving to the local filesystem LABEL="KDUMP TEST"
DUMPDEV=LABEL="KDUMP TEST"
IS_LABEL=`echo $DUMPDEV | grep LABEL`
IS_UUID=`echo $DUMPDEV | grep UUID`
if [ -n "$IS_LABEL" -o -n "$IS_UUID" ]
then
  DUMPDEV=`findfs $DUMPDEV`
fi
fsck.ext3 $DUMPDEV 
mount -t ext3 $DUMPDEV /mnt
if [ $? == 0 ]
then
  mkdir -p /mnt//var/crash/127.0.0.1-$DATE
  VMCORE=/mnt//var/crash/127.0.0.1-$DATE/vmcore
  export VMCORE
  monitor_cp_progress $VMCORE-incomplete &
  cp /proc/vmcore $VMCORE-incomplete >/dev/null
  exitcode=$?
  if [ $exitcode == 0 ]
  then 
      mv $VMCORE-incomplete $VMCORE
      echo -e "\\033[0JSaving core complete"
  fi 
fi
umount /mnt
[ $exitcode == 0 ] && reboot -f
echo Attempting to enter user-space to capture vmcore
...
Comment 4 CAI Qian 2008-09-26 02:26:29 EDT
Second test,
- config file
ext3 "LABEL=KDUMP TEST"

- start Kdump:
No kdump initial ramdisk found.[WARNING]
Rebuilding /boot/efi/efi/redhat/initrd-2.6.18-116.el5kdump.img

error: quote mismatch for LABEL=KDUMP

usage: find [-type type] [path [-name file]]
Starting kdump:[  OK  ]

- mkdumprd snip:
...
+ case "$config_opt" in
++ echo '#options'
++ grep '^#.*$'
+ IS_COMMENT='#options'
+ '[' -n '#options' -o -z 'modulename options' ']'
+ continue
+ read config_opt config_val
+ case "$config_opt" in
++ echo '#default'
++ grep '^#.*$'
+ IS_COMMENT='#default'
+ '[' -n '#default' -o -z shell ']'
+ continue
+ read config_opt config_val
+ case "$config_opt" in
++ echo ext3
++ grep '^#.*$'
+ IS_COMMENT=
+ '[' -n '' -o -z '"LABEL=KDUMP TEST"' ']'
+ USING_METHOD=filesystem
+ echo '"LABEL=KDUMP' 'TEST"'
+ egrep -q '^(LABEL|UUID)='
+ handlelvordev '"LABEL=KDUMP' 'TEST"'
++ lvs --noheadings -o vg_name '"LABEL=KDUMP'
+ local vg=
+ '[' -z '' ']'
+++ echo '"LABEL=KDUMP'
+++ sed -e 's#^/dev/mapper/\([^-]*\)-\(.*\)$#/dev/\1/\2#'
++ lvs --noheadings -o vg_name '"LABEL=KDUMP'
+ vg=
+ '[' -n '' ']'
+ findstoragedriver '"LABEL=KDUMP'
+ for device in '$@'
+ echo '"LABEL=KDUMP'
+ sed '-es/\/dev\///' '-es/[0-9]\+//'
+ case " $handleddevices " in
+ handleddevices=' cciss/c0d0p2 "LABEL=KDUMP'
...

- init from the initramfs snip:
...
echo Saving to the local filesystem "LABEL=KDUMP TEST"
DUMPDEV="LABEL=KDUMP TEST"
IS_LABEL=`echo $DUMPDEV | grep LABEL`
IS_UUID=`echo $DUMPDEV | grep UUID`
if [ -n "$IS_LABEL" -o -n "$IS_UUID" ]
then
  DUMPDEV=`findfs $DUMPDEV`
fi
fsck.ext3 $DUMPDEV
mount -t ext3 $DUMPDEV /mnt
if [ $? == 0 ]
then
  mkdir -p /mnt//var/crash/127.0.0.1-$DATE
  VMCORE=/mnt//var/crash/127.0.0.1-$DATE/vmcore
  export VMCORE
  monitor_cp_progress $VMCORE-incomplete &
  cp /proc/vmcore $VMCORE-incomplete >/dev/null
  exitcode=$?
  if [ $exitcode == 0 ]
  then
      mv $VMCORE-incomplete $VMCORE
      echo -e "\\033[0JSaving core complete"
  fi
fi
umount /mnt
[ $exitcode == 0 ] && reboot -f
echo Attempting to enter user-space to capture vmcore
echo Creating root device.
...
Comment 5 CAI Qian 2008-09-26 02:35:01 EDT
The working example,
- config file:
ext3 LABEL=KDUMP-TEST

- start Kdump:
Detected change(s) the following file(s):
  
  /etc/kdump.conf
Rebuilding /boot/efi/efi/redhat/initrd-2.6.18-116.el5kdump.img
Starting kdump:[  OK  ]

- mkdumprd snip:
...
+ case "$config_opt" in
++ echo '#default'
++ grep '^#.*$'
+ IS_COMMENT='#default'
+ '[' -n '#default' -o -z shell ']'
+ continue
+ read config_opt config_val
+ case "$config_opt" in
++ echo ext3
++ grep '^#.*$'
+ IS_COMMENT=
+ '[' -n '' -o -z LABEL=KDUMP-TEST ']'
+ USING_METHOD=filesystem
+ echo LABEL=KDUMP-TEST
+ egrep -q '^(LABEL|UUID)='
++ findfs LABEL=KDUMP-TEST
+ config_val=/dev/mapper/VolGroup00-LogVol00
+ handlelvordev /dev/mapper/VolGroup00-LogVol00
++ lvs --noheadings -o vg_name /dev/mapper/VolGroup00-LogVol00
+ local 'vg=  VolGroup00'
+ '[' -z '  VolGroup00' ']'
+ '[' -n '  VolGroup00' ']'
++ echo VolGroup00
+ vg=VolGroup00
+ case " $vg_list " in
+ read config_opt config_val
+ case "$config_opt" in
++ echo '#ext3'
++ grep '^#.*$'
+ IS_COMMENT='#ext3'
+ '[' -n '#ext3' -o -z /dev/mapper/VolGroup00-LogVol00 ']'
+ continue
+ read config_opt config_val
+ '[' -n '' -a '!' -e /sys/kernel/vmcoreinfo ']'
...

- init from the initramfs snip:
...
echo Saving to the local filesystem LABEL=KDUMP-TEST
DUMPDEV=LABEL=KDUMP-TEST
IS_LABEL=`echo $DUMPDEV | grep LABEL`
IS_UUID=`echo $DUMPDEV | grep UUID`
if [ -n "$IS_LABEL" -o -n "$IS_UUID" ]
then
  DUMPDEV=`findfs $DUMPDEV`
fi
fsck.ext3 $DUMPDEV
mount -t ext3 $DUMPDEV /mnt
if [ $? == 0 ]
then
  mkdir -p /mnt//var/crash/127.0.0.1-$DATE
  VMCORE=/mnt//var/crash/127.0.0.1-$DATE/vmcore
  export VMCORE
  monitor_cp_progress $VMCORE-incomplete &
  cp /proc/vmcore $VMCORE-incomplete >/dev/null
  exitcode=$?
  if [ $exitcode == 0 ]
  then
      mv $VMCORE-incomplete $VMCORE
      echo -e "\\033[0JSaving core complete"
  fi
fi
umount /mnt
[ $exitcode == 0 ] && reboot -f
echo Attempting to enter user-space to capture vmcore
echo Creating root device.
...
Comment 6 Neil Horman 2008-09-26 14:14:08 EDT
Created attachment 317822 [details]
new version of patch

Here you go.  I tested this one out and it fixed the problem for me.  Please confirm and I'll check it in ASAP.  Thanks!
Comment 7 CAI Qian 2008-09-26 23:25:25 EDT
Great! ext3 LABEL="KDUMP TEST" works. Thank you!
Comment 8 Neil Horman 2008-09-27 21:11:34 EDT
Great!  Thank Cai, I'll drum up the pm ack and get this checked in monday ASAP.
Comment 9 Neil Horman 2008-09-29 11:34:35 EDT
fixed in -42.el5.
Comment 12 Neil Horman 2008-10-07 11:51:47 EDT
You know, that kdump_chk value is just looking to verify the presence of binaries, we really don't need it.  I'm removing it entirely, its not worth the effort to keep around.  Fixed in -46
Comment 13 Neil Horman 2008-10-17 15:49:11 EDT
*** Bug 467483 has been marked as a duplicate of this bug. ***
Comment 16 Neil Horman 2008-10-23 10:54:41 EDT
*** Bug 468114 has been marked as a duplicate of this bug. ***
Comment 17 Larry Troan 2008-11-04 09:03:03 EST
>Comment #14 From  Issue Tracker (tao@redhat.com) 2008-10-19 21:53:23 EDT [edited]
>---
>I confirmed this problem is fixed by using kexec-tools-1.102pre-46.el5.
Comment 20 errata-xmlrpc 2009-01-20 15:59:59 EST
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-0105.html

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