mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-19 14:04:17 +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:
parent
1acad23d68
commit
2562968864
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.99 -
|
Version 2.02.99 -
|
||||||
===================================
|
===================================
|
||||||
|
Fix vgcfgrestore crash when specified incorrect vg name.
|
||||||
Refine lvm.conf and man page documentation for autoactivation feature.
|
Refine lvm.conf and man page documentation for autoactivation feature.
|
||||||
Add support for thin volumes in vgsplit.
|
Add support for thin volumes in vgsplit.
|
||||||
Also filter partitions on mpath components if multipath_component_detection=1.
|
Also filter partitions on mpath components if multipath_component_detection=1.
|
||||||
|
@ -857,6 +857,7 @@ static struct volume_group *_vg_read_file_name(struct format_instance *fid,
|
|||||||
* check that it contains the correct volume group.
|
* check that it contains the correct volume group.
|
||||||
*/
|
*/
|
||||||
if (vgname && strcmp(vgname, vg->name)) {
|
if (vgname && strcmp(vgname, vg->name)) {
|
||||||
|
fid->ref_count++; /* Preserve FID after vg release */
|
||||||
release_vg(vg);
|
release_vg(vg);
|
||||||
log_error("'%s' does not contain volume group '%s'.",
|
log_error("'%s' does not contain volume group '%s'.",
|
||||||
read_path, vgname);
|
read_path, vgname);
|
||||||
|
@ -38,6 +38,9 @@ vgcfgbackup -f "$(pwd)/backup.$$" $vg
|
|||||||
sed 's/flags = \[\"MISSING\"\]/flags = \[\]/' "$(pwd)/backup.$$" > "$(pwd)/backup.$$1"
|
sed 's/flags = \[\"MISSING\"\]/flags = \[\]/' "$(pwd)/backup.$$" > "$(pwd)/backup.$$1"
|
||||||
pvcreate -ff -y --norestorefile -u $pv1_uuid "$dev1"
|
pvcreate -ff -y --norestorefile -u $pv1_uuid "$dev1"
|
||||||
pvcreate -ff -y --norestorefile -u $pv2_uuid "$dev2"
|
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
|
vgcfgrestore -f "$(pwd)/backup.$$1" $vg
|
||||||
vgremove -ff $vg
|
vgremove -ff $vg
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user