diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2013-06-18 21:50:29 +0200 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2013-06-18 22:11:21 +0200 |
commit | 25629688643958e12859af0d53e818b8b111b4a9 (patch) | |
tree | 516139e7a7897ef3b5dac0bd4b4febc48988a32e | |
parent | 1acad23d68b6b82a297fb4106f016ae7a15fcf1a (diff) | |
download | lvm2-25629688643958e12859af0d53e818b8b111b4a9.tar.gz |
vgcfgrestore: fix crash on restore of wrong vgname
When vgname has not existed in metadata, it has crashed on double free
in format_instance destroy() - since VG was created, used FID and was
released - which also released FID, so further use was accessing bad
memory.
Fix it for this code path before release_vg() so FID will exists
when _vg_read_file_name() returns NULL.
-rw-r--r-- | WHATS_NEW | 1 | ||||
-rw-r--r-- | lib/format_text/format-text.c | 1 | ||||
-rw-r--r-- | test/shell/vgcfgbackup-usage.sh | 3 |
3 files changed, 5 insertions, 0 deletions
@@ -1,5 +1,6 @@ Version 2.02.99 - =================================== + Fix vgcfgrestore crash when specified incorrect vg name. Refine lvm.conf and man page documentation for autoactivation feature. Add support for thin volumes in vgsplit. Also filter partitions on mpath components if multipath_component_detection=1. diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index 1a1613451..315725273 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -857,6 +857,7 @@ static struct volume_group *_vg_read_file_name(struct format_instance *fid, * check that it contains the correct volume group. */ if (vgname && strcmp(vgname, vg->name)) { + fid->ref_count++; /* Preserve FID after vg release */ release_vg(vg); log_error("'%s' does not contain volume group '%s'.", read_path, vgname); diff --git a/test/shell/vgcfgbackup-usage.sh b/test/shell/vgcfgbackup-usage.sh index c8245b06c..7a1e53016 100644 --- a/test/shell/vgcfgbackup-usage.sh +++ b/test/shell/vgcfgbackup-usage.sh @@ -38,6 +38,9 @@ vgcfgbackup -f "$(pwd)/backup.$$" $vg sed 's/flags = \[\"MISSING\"\]/flags = \[\]/' "$(pwd)/backup.$$" > "$(pwd)/backup.$$1" pvcreate -ff -y --norestorefile -u $pv1_uuid "$dev1" pvcreate -ff -y --norestorefile -u $pv2_uuid "$dev2" + +# Try to recover nonexisting vgname +not vgcfgrestore -f "$(pwd)/backup.$$1" ${vg}_nonexistent vgcfgrestore -f "$(pwd)/backup.$$1" $vg vgremove -ff $vg |