1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/lib/format_text
Zdenek Kabelac b680d5bf7b 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 13:13:40 +00:00
..
archive.c Various cleanups for fid mem and ref_count changes. 2011-03-11 15:08:31 +00:00
archiver.c Various cleanups for fid mem and ref_count changes. 2011-03-11 15:08:31 +00:00
archiver.h Fix remote metadata backup for clvmd 2009-04-22 09:39:45 +00:00
export.c Add missing printf attributes 2011-04-08 14:21:34 +00:00
flags.c s/MIRROR_NOTSYNCED/LV_NOTSYNCED/ - Flag will may refer to more than just mirrors 2011-03-29 12:51:57 +00:00
format-text.c Fix use of released vgname and vgid 2011-04-21 13:13:40 +00:00
format-text.h Make create_text_context fn static and move it inside create_instance fn. 2011-03-11 14:45:17 +00:00
import_vsn1.c Rename _check_version 2011-03-27 13:44:08 +00:00
import-export.h Add more strict const pointers around config tree 2010-12-20 13:12:55 +00:00
import.c Change import_vg_from_buffer to use config_tree 2011-01-10 13:13:42 +00:00
layout.h more metadataignore message/code cleanup 2010-06-30 17:13:05 +00:00
tags.c Add more strict const pointers around config tree 2010-12-20 13:12:55 +00:00
text_export.h Export function out_text_with_comment() and add outfc() macro that checks 2010-01-07 14:45:28 +00:00
text_import.h Update a few more uint64_t's related to the 64-bit status change. 2009-12-04 17:48:32 +00:00
text_label.c Void* arithmetic replaced with char* 2011-02-18 14:34:41 +00:00