diff options
author | Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> | 2021-03-08 16:07:11 +0000 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-04-12 17:17:11 -0400 |
commit | d46933839f98d8cdb34fc87299b5f2a4ec4bbfec (patch) | |
tree | a5b50124886981da1c9a84b143945c0b1f4cb75e /disk/part_efi.c | |
parent | b935d190662306b4174a8f7e3dbd6194c5f55ecb (diff) | |
download | u-boot-d46933839f98d8cdb34fc87299b5f2a4ec4bbfec.zip u-boot-d46933839f98d8cdb34fc87299b5f2a4ec4bbfec.tar.gz u-boot-d46933839f98d8cdb34fc87299b5f2a4ec4bbfec.tar.bz2 |
disk: gpt: verify alternate LBA points to last usable LBA
The gpt command require the GPT backup header at the standard location
at the end of the device. Check the alternate LBA value before reading
the GPT backup header from the last usable LBA of the device.
Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'disk/part_efi.c')
-rw-r--r-- | disk/part_efi.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/disk/part_efi.c b/disk/part_efi.c index e5636ea..0fb7ff0 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -692,6 +692,15 @@ int gpt_verify_headers(struct blk_desc *dev_desc, gpt_header *gpt_head, /* Free pte before allocating again */ free(*gpt_pte); + /* + * Check that the alternate_lba entry points to the last LBA + */ + if (le64_to_cpu(gpt_head->alternate_lba) != (dev_desc->lba - 1)) { + printf("%s: *** ERROR: Misplaced Backup GPT ***\n", + __func__); + return -1; + } + if (is_gpt_valid(dev_desc, (dev_desc->lba - 1), gpt_head, gpt_pte) != 1) { printf("%s: *** ERROR: Invalid Backup GPT ***\n", |