1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
lvm2/test/shell/pv-duplicate.sh

41 lines
978 B
Bash
Raw Normal View History

Fix use of released vgname and vgid Avoid using of already released memory when duplicated MDA is found. As get_pv_from_vg_by_id() may call lvmcache_label_scan() use the local copy of the vgname and vgid on the stack as vginfo may dissapear and code was then accessing garbage in memory. i.e. pvs /dev/loop0 (when /dev/loop0 and /dev/loop1 has same MDA content) Invalid read of size 1 at 0x523C986: dm_hash_lookup (hash.c:325) by 0x440C8C: vginfo_from_vgname (lvmcache.c:399) by 0x4605C0: _create_vg_text_instance (format-text.c:1882) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) by 0x47FBD8: vg_read_internal (metadata.c:3231) by 0x477594: get_pv_from_vg_by_id (metadata.c:344) by 0x45F07A: _get_pv_if_in_vg (format-text.c:1400) by 0x45F0B9: _populate_pv_fields (format-text.c:1414) by 0x45F40F: _text_pv_read (format-text.c:1493) by 0x480431: _pv_read (metadata.c:3500) by 0x4802B2: pv_read (metadata.c:3462) Address 0x652ab80 is 0 bytes inside a block of size 4 free'd at 0x4C2756E: free (vg_replace_malloc.c:366) by 0x442277: _free_vginfo (lvmcache.c:963) by 0x44235E: _drop_vginfo (lvmcache.c:992) by 0x442B23: _lvmcache_update_vgname (lvmcache.c:1165) by 0x443449: lvmcache_update_vgname_and_id (lvmcache.c:1358) by 0x443C07: lvmcache_add (lvmcache.c:1492) by 0x46588C: _text_read (text_label.c:271) by 0x466A65: label_read (label.c:289) by 0x4413FC: lvmcache_label_scan (lvmcache.c:635) by 0x4605AD: _create_vg_text_instance (format-text.c:1881) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) Add testing script
2011-04-21 17:13:40 +04:00
#!/bin/sh
2015-04-02 13:42:56 +03:00
# Copyright (C) 2011-2015 Red Hat, Inc. All rights reserved.
Fix use of released vgname and vgid Avoid using of already released memory when duplicated MDA is found. As get_pv_from_vg_by_id() may call lvmcache_label_scan() use the local copy of the vgname and vgid on the stack as vginfo may dissapear and code was then accessing garbage in memory. i.e. pvs /dev/loop0 (when /dev/loop0 and /dev/loop1 has same MDA content) Invalid read of size 1 at 0x523C986: dm_hash_lookup (hash.c:325) by 0x440C8C: vginfo_from_vgname (lvmcache.c:399) by 0x4605C0: _create_vg_text_instance (format-text.c:1882) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) by 0x47FBD8: vg_read_internal (metadata.c:3231) by 0x477594: get_pv_from_vg_by_id (metadata.c:344) by 0x45F07A: _get_pv_if_in_vg (format-text.c:1400) by 0x45F0B9: _populate_pv_fields (format-text.c:1414) by 0x45F40F: _text_pv_read (format-text.c:1493) by 0x480431: _pv_read (metadata.c:3500) by 0x4802B2: pv_read (metadata.c:3462) Address 0x652ab80 is 0 bytes inside a block of size 4 free'd at 0x4C2756E: free (vg_replace_malloc.c:366) by 0x442277: _free_vginfo (lvmcache.c:963) by 0x44235E: _drop_vginfo (lvmcache.c:992) by 0x442B23: _lvmcache_update_vgname (lvmcache.c:1165) by 0x443449: lvmcache_update_vgname_and_id (lvmcache.c:1358) by 0x443C07: lvmcache_add (lvmcache.c:1492) by 0x46588C: _text_read (text_label.c:271) by 0x466A65: label_read (label.c:289) by 0x4413FC: lvmcache_label_scan (lvmcache.c:635) by 0x4605AD: _create_vg_text_instance (format-text.c:1881) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) Add testing script
2011-04-21 17:13:40 +04:00
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Fix use of released vgname and vgid Avoid using of already released memory when duplicated MDA is found. As get_pv_from_vg_by_id() may call lvmcache_label_scan() use the local copy of the vgname and vgid on the stack as vginfo may dissapear and code was then accessing garbage in memory. i.e. pvs /dev/loop0 (when /dev/loop0 and /dev/loop1 has same MDA content) Invalid read of size 1 at 0x523C986: dm_hash_lookup (hash.c:325) by 0x440C8C: vginfo_from_vgname (lvmcache.c:399) by 0x4605C0: _create_vg_text_instance (format-text.c:1882) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) by 0x47FBD8: vg_read_internal (metadata.c:3231) by 0x477594: get_pv_from_vg_by_id (metadata.c:344) by 0x45F07A: _get_pv_if_in_vg (format-text.c:1400) by 0x45F0B9: _populate_pv_fields (format-text.c:1414) by 0x45F40F: _text_pv_read (format-text.c:1493) by 0x480431: _pv_read (metadata.c:3500) by 0x4802B2: pv_read (metadata.c:3462) Address 0x652ab80 is 0 bytes inside a block of size 4 free'd at 0x4C2756E: free (vg_replace_malloc.c:366) by 0x442277: _free_vginfo (lvmcache.c:963) by 0x44235E: _drop_vginfo (lvmcache.c:992) by 0x442B23: _lvmcache_update_vgname (lvmcache.c:1165) by 0x443449: lvmcache_update_vgname_and_id (lvmcache.c:1358) by 0x443C07: lvmcache_add (lvmcache.c:1492) by 0x46588C: _text_read (text_label.c:271) by 0x466A65: label_read (label.c:289) by 0x4413FC: lvmcache_label_scan (lvmcache.c:635) by 0x4605AD: _create_vg_text_instance (format-text.c:1881) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) Add testing script
2011-04-21 17:13:40 +04:00
# 'Exercise duplicate metadata diagnostics'
SKIP_WITH_LVMLOCKD=1
SKIP_WITH_LVMPOLLD=1
Fix use of released vgname and vgid Avoid using of already released memory when duplicated MDA is found. As get_pv_from_vg_by_id() may call lvmcache_label_scan() use the local copy of the vgname and vgid on the stack as vginfo may dissapear and code was then accessing garbage in memory. i.e. pvs /dev/loop0 (when /dev/loop0 and /dev/loop1 has same MDA content) Invalid read of size 1 at 0x523C986: dm_hash_lookup (hash.c:325) by 0x440C8C: vginfo_from_vgname (lvmcache.c:399) by 0x4605C0: _create_vg_text_instance (format-text.c:1882) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) by 0x47FBD8: vg_read_internal (metadata.c:3231) by 0x477594: get_pv_from_vg_by_id (metadata.c:344) by 0x45F07A: _get_pv_if_in_vg (format-text.c:1400) by 0x45F0B9: _populate_pv_fields (format-text.c:1414) by 0x45F40F: _text_pv_read (format-text.c:1493) by 0x480431: _pv_read (metadata.c:3500) by 0x4802B2: pv_read (metadata.c:3462) Address 0x652ab80 is 0 bytes inside a block of size 4 free'd at 0x4C2756E: free (vg_replace_malloc.c:366) by 0x442277: _free_vginfo (lvmcache.c:963) by 0x44235E: _drop_vginfo (lvmcache.c:992) by 0x442B23: _lvmcache_update_vgname (lvmcache.c:1165) by 0x443449: lvmcache_update_vgname_and_id (lvmcache.c:1358) by 0x443C07: lvmcache_add (lvmcache.c:1492) by 0x46588C: _text_read (text_label.c:271) by 0x466A65: label_read (label.c:289) by 0x4413FC: lvmcache_label_scan (lvmcache.c:635) by 0x4605AD: _create_vg_text_instance (format-text.c:1881) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) Add testing script
2011-04-21 17:13:40 +04:00
. lib/inittest
Fix use of released vgname and vgid Avoid using of already released memory when duplicated MDA is found. As get_pv_from_vg_by_id() may call lvmcache_label_scan() use the local copy of the vgname and vgid on the stack as vginfo may dissapear and code was then accessing garbage in memory. i.e. pvs /dev/loop0 (when /dev/loop0 and /dev/loop1 has same MDA content) Invalid read of size 1 at 0x523C986: dm_hash_lookup (hash.c:325) by 0x440C8C: vginfo_from_vgname (lvmcache.c:399) by 0x4605C0: _create_vg_text_instance (format-text.c:1882) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) by 0x47FBD8: vg_read_internal (metadata.c:3231) by 0x477594: get_pv_from_vg_by_id (metadata.c:344) by 0x45F07A: _get_pv_if_in_vg (format-text.c:1400) by 0x45F0B9: _populate_pv_fields (format-text.c:1414) by 0x45F40F: _text_pv_read (format-text.c:1493) by 0x480431: _pv_read (metadata.c:3500) by 0x4802B2: pv_read (metadata.c:3462) Address 0x652ab80 is 0 bytes inside a block of size 4 free'd at 0x4C2756E: free (vg_replace_malloc.c:366) by 0x442277: _free_vginfo (lvmcache.c:963) by 0x44235E: _drop_vginfo (lvmcache.c:992) by 0x442B23: _lvmcache_update_vgname (lvmcache.c:1165) by 0x443449: lvmcache_update_vgname_and_id (lvmcache.c:1358) by 0x443C07: lvmcache_add (lvmcache.c:1492) by 0x46588C: _text_read (text_label.c:271) by 0x466A65: label_read (label.c:289) by 0x4413FC: lvmcache_label_scan (lvmcache.c:635) by 0x4605AD: _create_vg_text_instance (format-text.c:1881) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) Add testing script
2011-04-21 17:13:40 +04:00
aux prepare_devs 3
2015-04-02 13:42:56 +03:00
pvcreate "$dev1"
dd if="$dev1" of=backup_dev1 bs=256K count=1
vgcreate --metadatasize 128k $vg1 "$dev1"
Fix use of released vgname and vgid Avoid using of already released memory when duplicated MDA is found. As get_pv_from_vg_by_id() may call lvmcache_label_scan() use the local copy of the vgname and vgid on the stack as vginfo may dissapear and code was then accessing garbage in memory. i.e. pvs /dev/loop0 (when /dev/loop0 and /dev/loop1 has same MDA content) Invalid read of size 1 at 0x523C986: dm_hash_lookup (hash.c:325) by 0x440C8C: vginfo_from_vgname (lvmcache.c:399) by 0x4605C0: _create_vg_text_instance (format-text.c:1882) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) by 0x47FBD8: vg_read_internal (metadata.c:3231) by 0x477594: get_pv_from_vg_by_id (metadata.c:344) by 0x45F07A: _get_pv_if_in_vg (format-text.c:1400) by 0x45F0B9: _populate_pv_fields (format-text.c:1414) by 0x45F40F: _text_pv_read (format-text.c:1493) by 0x480431: _pv_read (metadata.c:3500) by 0x4802B2: pv_read (metadata.c:3462) Address 0x652ab80 is 0 bytes inside a block of size 4 free'd at 0x4C2756E: free (vg_replace_malloc.c:366) by 0x442277: _free_vginfo (lvmcache.c:963) by 0x44235E: _drop_vginfo (lvmcache.c:992) by 0x442B23: _lvmcache_update_vgname (lvmcache.c:1165) by 0x443449: lvmcache_update_vgname_and_id (lvmcache.c:1358) by 0x443C07: lvmcache_add (lvmcache.c:1492) by 0x46588C: _text_read (text_label.c:271) by 0x466A65: label_read (label.c:289) by 0x4413FC: lvmcache_label_scan (lvmcache.c:635) by 0x4605AD: _create_vg_text_instance (format-text.c:1881) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) Add testing script
2011-04-21 17:13:40 +04:00
# copy mda
dd if="$dev1" of="$dev2" bs=256K count=1
dd if="$dev1" of="$dev3" bs=256K count=1
Fix use of released vgname and vgid Avoid using of already released memory when duplicated MDA is found. As get_pv_from_vg_by_id() may call lvmcache_label_scan() use the local copy of the vgname and vgid on the stack as vginfo may dissapear and code was then accessing garbage in memory. i.e. pvs /dev/loop0 (when /dev/loop0 and /dev/loop1 has same MDA content) Invalid read of size 1 at 0x523C986: dm_hash_lookup (hash.c:325) by 0x440C8C: vginfo_from_vgname (lvmcache.c:399) by 0x4605C0: _create_vg_text_instance (format-text.c:1882) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) by 0x47FBD8: vg_read_internal (metadata.c:3231) by 0x477594: get_pv_from_vg_by_id (metadata.c:344) by 0x45F07A: _get_pv_if_in_vg (format-text.c:1400) by 0x45F0B9: _populate_pv_fields (format-text.c:1414) by 0x45F40F: _text_pv_read (format-text.c:1493) by 0x480431: _pv_read (metadata.c:3500) by 0x4802B2: pv_read (metadata.c:3462) Address 0x652ab80 is 0 bytes inside a block of size 4 free'd at 0x4C2756E: free (vg_replace_malloc.c:366) by 0x442277: _free_vginfo (lvmcache.c:963) by 0x44235E: _drop_vginfo (lvmcache.c:992) by 0x442B23: _lvmcache_update_vgname (lvmcache.c:1165) by 0x443449: lvmcache_update_vgname_and_id (lvmcache.c:1358) by 0x443C07: lvmcache_add (lvmcache.c:1492) by 0x46588C: _text_read (text_label.c:271) by 0x466A65: label_read (label.c:289) by 0x4413FC: lvmcache_label_scan (lvmcache.c:635) by 0x4605AD: _create_vg_text_instance (format-text.c:1881) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) Add testing script
2011-04-21 17:13:40 +04:00
pvs "$dev3" -o pv_uuid
2015-04-02 13:42:56 +03:00
Fix use of released vgname and vgid Avoid using of already released memory when duplicated MDA is found. As get_pv_from_vg_by_id() may call lvmcache_label_scan() use the local copy of the vgname and vgid on the stack as vginfo may dissapear and code was then accessing garbage in memory. i.e. pvs /dev/loop0 (when /dev/loop0 and /dev/loop1 has same MDA content) Invalid read of size 1 at 0x523C986: dm_hash_lookup (hash.c:325) by 0x440C8C: vginfo_from_vgname (lvmcache.c:399) by 0x4605C0: _create_vg_text_instance (format-text.c:1882) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) by 0x47FBD8: vg_read_internal (metadata.c:3231) by 0x477594: get_pv_from_vg_by_id (metadata.c:344) by 0x45F07A: _get_pv_if_in_vg (format-text.c:1400) by 0x45F0B9: _populate_pv_fields (format-text.c:1414) by 0x45F40F: _text_pv_read (format-text.c:1493) by 0x480431: _pv_read (metadata.c:3500) by 0x4802B2: pv_read (metadata.c:3462) Address 0x652ab80 is 0 bytes inside a block of size 4 free'd at 0x4C2756E: free (vg_replace_malloc.c:366) by 0x442277: _free_vginfo (lvmcache.c:963) by 0x44235E: _drop_vginfo (lvmcache.c:992) by 0x442B23: _lvmcache_update_vgname (lvmcache.c:1165) by 0x443449: lvmcache_update_vgname_and_id (lvmcache.c:1358) by 0x443C07: lvmcache_add (lvmcache.c:1492) by 0x46588C: _text_read (text_label.c:271) by 0x466A65: label_read (label.c:289) by 0x4413FC: lvmcache_label_scan (lvmcache.c:635) by 0x4605AD: _create_vg_text_instance (format-text.c:1881) by 0x46140D: _text_create_text_instance (format-text.c:2243) by 0x47EB49: _vg_read (metadata.c:2887) Add testing script
2011-04-21 17:13:40 +04:00
vgs $vg1
2015-04-02 13:42:56 +03:00
dd if=backup_dev1 of="$dev3" bs=256K count=1
pvs
#-vvvv
# TODO: Surely needs more inspecition about correct
# behavior for such case
# vgs $vg1