* grub-core/disk/diskfilter.c (insert_array): Choose the smallest
device. * grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Reject too small devices.
This commit is contained in:
parent
036985b8ce
commit
1e9a9a3faf
3 changed files with 36 additions and 23 deletions
|
@ -1,3 +1,10 @@
|
|||
2012-02-26 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/diskfilter.c (insert_array): Choose the smallest
|
||||
device.
|
||||
* grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Reject too
|
||||
small devices.
|
||||
|
||||
2012-02-26 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Remove grub_{modname}_init and grub_{modname}_fini. They should never
|
||||
|
|
|
@ -966,13 +966,14 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id,
|
|||
struct grub_diskfilter_lv *lv;
|
||||
/* FIXME: Check whether the update time of the superblocks are
|
||||
the same. */
|
||||
/* This could happen to LVM on RAID, pv->disk points to the
|
||||
raid device, we shouldn't change it. */
|
||||
if (! pv->disk)
|
||||
{
|
||||
if (pv->disk && grub_disk_get_size (disk) >= pv->part_size)
|
||||
return GRUB_ERR_NONE;
|
||||
pv->disk = grub_disk_open (disk->name);
|
||||
if (!pv->disk)
|
||||
return grub_errno;
|
||||
/* This could happen to LVM on RAID, pv->disk points to the
|
||||
raid device, we shouldn't change it. */
|
||||
pv->start_sector -= pv->part_start;
|
||||
pv->part_start = grub_partition_get_start (disk->partition);
|
||||
pv->part_size = grub_disk_get_size (disk);
|
||||
|
||||
|
@ -992,7 +993,6 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id,
|
|||
if (start_sector != (grub_uint64_t)-1)
|
||||
pv->start_sector = start_sector;
|
||||
pv->start_sector += pv->part_start;
|
||||
}
|
||||
/* Add the device to the array. */
|
||||
for (lv = array->lvs; lv; lv = lv->next)
|
||||
if (!lv->became_readable_at && lv->fullname && is_lv_readable (lv))
|
||||
|
|
|
@ -192,6 +192,11 @@ grub_mdraid_detect (grub_disk_t disk,
|
|||
/* Unsupported version. */
|
||||
return NULL;
|
||||
|
||||
/* No need for explicit check that sb.size is 0 (unspecified) since
|
||||
0 >= non-0 is false. */
|
||||
if (((grub_disk_addr_t) grub_le_to_cpu32 (sb.size)) * 2 >= size)
|
||||
return NULL;
|
||||
|
||||
/* FIXME: Check the checksum. */
|
||||
|
||||
level = grub_le_to_cpu32 (sb.level);
|
||||
|
@ -229,7 +234,8 @@ grub_mdraid_detect (grub_disk_t disk,
|
|||
grub_snprintf (buf, sizeof (buf), "md%d", grub_le_to_cpu32 (sb.md_minor));
|
||||
return grub_diskfilter_make_raid (16, (char *) uuid,
|
||||
grub_le_to_cpu32 (sb.raid_disks), buf,
|
||||
(sb.size) ? grub_le_to_cpu32 (sb.size) * 2
|
||||
(sb.size) ? ((grub_disk_addr_t)
|
||||
grub_le_to_cpu32 (sb.size)) * 2
|
||||
: sector,
|
||||
grub_le_to_cpu32 (sb.chunk_size) >> 9,
|
||||
grub_le_to_cpu32 (sb.layout),
|
||||
|
|
Loading…
Reference in a new issue