1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

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.
This commit is contained in:
Zdenek Kabelac 2013-06-18 21:50:29 +02:00
parent 1acad23d68
commit 2562968864
3 changed files with 5 additions and 0 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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