* grub-core/fs/zfs/zfs.c (check_pool_label): Check nvlist.

This commit is contained in:
Massimo Maggi 2013-09-23 18:50:07 +02:00 committed by Vladimir 'phcoder' Serbinenko
parent 9c262ff966
commit 890bdabe96
2 changed files with 26 additions and 0 deletions

View file

@ -1,3 +1,7 @@
2013-09-23 Massimo Maggi <me@massimo-maggi.eu>
* grub-core/fs/zfs/zfs.c (check_pool_label): Check nvlist.
2013-09-23 Tim Hardeck <thardeck>
* util/grub.d/10_hurd.in: Filter out character for the class.

View file

@ -969,6 +969,9 @@ check_pool_label (struct grub_zfs_data *data,
grub_uint64_t version;
int found;
grub_err_t err;
grub_zfs_endian_t endian;
vdev_phys_t *phys;
zio_cksum_t emptycksum;
*inserted = 0;
@ -976,6 +979,25 @@ check_pool_label (struct grub_zfs_data *data,
if (err)
return err;
phys = (vdev_phys_t*) nvlist;
if (grub_zfs_to_cpu64 (phys->vp_zbt.zec_magic,
GRUB_ZFS_LITTLE_ENDIAN)
== ZEC_MAGIC)
endian = GRUB_ZFS_LITTLE_ENDIAN;
else if (grub_zfs_to_cpu64 (phys->vp_zbt.zec_magic,
GRUB_ZFS_BIG_ENDIAN)
== ZEC_MAGIC)
endian = GRUB_ZFS_BIG_ENDIAN;
else
return grub_error (GRUB_ERR_BAD_FS,
"bad vdev_phys_t.vp_zbt.zec_magic number");
/* Now check the integrity of the vdev_phys_t structure though checksum. */
ZIO_SET_CHECKSUM(&emptycksum, diskdesc->vdev_phys_sector << 9, 0, 0, 0);
err = zio_checksum_verify (emptycksum, ZIO_CHECKSUM_LABEL, endian,
nvlist, VDEV_PHYS_SIZE);
if (err)
return err;
grub_dprintf ("zfs", "check 2 passed\n");
found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_STATE,