Skip to content

Commit

Permalink
txt/verify.c: fix miscalculated offset to extended data elements
Browse files Browse the repository at this point in the history
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
  • Loading branch information
krystian-hebel committed Feb 13, 2024
1 parent 622eb9c commit efdb40d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions grub-core/loader/i386/txt/verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ grub_txt_verify_platform (void)
N_("TXT heap is not configured correctly"));

bios_size = grub_txt_bios_data_size (txt_heap);
/* We support versions >= 4, but bios_data->mle_flags is in versions >= 5. */
if ( bios_size < sizeof (grub_uint64_t) + sizeof (*bios_data) -
sizeof (bios_data->mle_flags) ||
if ( bios_size < sizeof (grub_uint64_t) + sizeof (*bios_data) ||
bios_size > heap_size )
return grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("invalid size of the TXT heap BIOS data table"));
Expand All @@ -264,16 +262,15 @@ grub_txt_verify_platform (void)
bios_data->num_logical_procs);

/*
* grub_uint32_t mle_flags is available in versions >= 5, version 4 doesn't
* have it. However, the minimal size of extended data element is 8 bytes, so
* the size check below is still valid for version 4.
* grub_uint32_t mle_flags is supposed to be added in version 5, however, the
* only ACM in 630744_003 package that is version 4 (Sandy Bridge & Ivy Bridge
* SNB_IVB_SINIT_20190708_PW.bin) seems to also have this field, or at least
* a placeholder for it.
*/
if ( bios_data->version >= 4 && bios_size > sizeof(*bios_data) + sizeof(bios_size) )
{
elts = (struct grub_txt_heap_ext_data_element *) ((grub_uint8_t *)bios_data +
sizeof(*bios_data) -
( bios_data->version == 4 ?
sizeof(bios_data->mle_flags) : 0 ));
sizeof(*bios_data));
err = verify_ext_data_elts(elts, bios_size - sizeof(*bios_data));
}

Expand Down

0 comments on commit efdb40d

Please sign in to comment.