1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/lib/format_text
Peter Rajnoha 34d207d9b3 lvmetad: fix mda offset/size overflow if >= 4g (32bit)
When reading an info about MDAs from lvmetad, we need to use 64 bit
int to read the value of the offset/size, otherwise the value is
overflows and then it's used throughout!

This is dangerous if we're trying to write such metadata area then,
mostly visible if we're using 2 mdas where the 2nd one is at the end
of the underlying device and hence the value of the mda offset is
high enough to cause problems:

(the offset trimmed to value of 0 instead of 4096m, so we write
at the very start of the disk (or elsewhere if the offset has
some other value!)

[1] raw/~ # lvcreate -s -l 100%FREE vg --virtualsize 4097m
  Logical volume "lvol0" created

[1] raw/~ # pvcreate --metadatacopies 2 /dev/vg/lvol0
  Physical volume "/dev/vg/lvol0" successfully created

[1] raw/~ # hexdump -n 512 /dev/vg/lvol0
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0000200

[1] raw/~ # pvchange -u /dev/vg/lvol0
  Physical volume "/dev/vg/lvol0" changed
  1 physical volume changed / 0 physical volumes not changed

[1] raw/~ # hexdump -n 512 /dev/vg/lvol0
0000000 d43e d2a5 4c20 4d56 2032 5b78 4135 7225
0000010 4e30 3e2a 0001 0000 0000 0000 0000 0000
0000020 0000 0010 0000 0000 0000 0000 0000 0000
0000030 0000 0000 0000 0000 0000 0000 0000 0000
*
0000200

=======

(the offset overflows to undefined values which is far behind
the end of the disk)

[1] raw/~ # lvcreate -s -l 100%FREE vg --virtualsize 100g
  Logical volume "lvol0" created

[1] raw/~ # pvcreate --metadatacopies 2 /dev/vg/lvol0
  Physical volume "/dev/vg/lvol0" successfully created

[1] raw/~ # pvchange -u /dev/vg/lvol0
  /dev/vg/lvol0: lseek 18446744073708503040 failed: Invalid argument
  /dev/vg/lvol0: lseek 18446744073708503040 failed: Invalid argument
  Failed to store physical volume "/dev/vg/lvol0"
  0 physical volumes changed / 1 physical volume not changed
2013-08-06 13:37:42 +02:00
..
archive.c cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00
archiver.c cleanup: use dm_list_empty 2013-07-18 18:22:42 +02:00
archiver.h thin: allow restore with --force 2012-11-27 14:08:24 +01:00
export.c metadata: add support for storing profile name in metadata (during vgcreate/lvcreate) 2013-07-02 15:19:09 +02:00
flags.c thin: add pool metadata spare lv support 2013-07-18 18:22:43 +02:00
format-text.c lvmetad: fix mda offset/size overflow if >= 4g (32bit) 2013-08-06 13:37:42 +02:00
format-text.h refactor: rename embedding area -> bootloader area 2013-05-28 12:37:22 +02:00
import_vsn1.c thin: add pool metadata spare lv support 2013-07-18 18:22:43 +02:00
import-export.h Pass 'single_device' parameter down to suppress 'Can't find uuid' messages 2012-02-29 02:35:35 +00:00
import.c config: add config_source_t type to identify configuration source 2013-07-02 15:19:08 +02:00
layout.h refactor: rename embedding area -> bootloader area 2013-05-28 12:37:22 +02:00
tags.c Move the core of the lib/config/config.c functionality into libdevmapper, 2011-08-30 14:55:15 +00:00
text_export.h Move the core of the lib/config/config.c functionality into libdevmapper, 2011-08-30 14:55:15 +00:00
text_import.h Replace const usage of dm_config_find_node with more appropriate value-lookup 2011-08-31 15:19:19 +00:00
text_label.c refactor: rename embedding area -> bootloader area 2013-05-28 12:37:22 +02:00