[PATCH] partitions: efi: Check GPT header size against minimum limit
Alexander Shiyan
eagle.alexander923 at gmail.com
Wed Dec 4 10:18:58 PST 2024
Hello.
Maybe it's better to use sizeof(struct _gpt_header) ?
Thanks!
ср, 4 дек. 2024 г. в 18:30, Abdelrahman Youssef <abdelrahmanyossef12 at gmail.com>:
>
> In https://git.pengutronix.de/cgit/barebox/commit/?id=a9c6ad764144, we were
> checking if the GPT header size is exceeding the maximum limit.
>
> This is a follow-up patch to check if the header size is less than
> the minimum limit which is 92 as per this documentation
> https://uefi.org/specs/UEFI/2.10/05_GUID_Partition_Table_Format.html#id14
>
> Signed-off-by: Abdelrahman Youssef <abdelrahmanyossef12 at gmail.com>
> ---
> common/partitions/efi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/common/partitions/efi.c b/common/partitions/efi.c
> index 8014579b67..a4e60c3c98 100644
> --- a/common/partitions/efi.c
> +++ b/common/partitions/efi.c
> @@ -190,7 +190,8 @@ static int is_gpt_valid(struct block_device *blk, u64 lba,
> goto fail;
> }
>
> - if (le32_to_cpu((*gpt)->header_size) > bdev_logical_block_size(blk))
> + if (le32_to_cpu((*gpt)->header_size) < 92 ||
> + le32_to_cpu((*gpt)->header_size) > bdev_logical_block_size(blk))
> goto fail;
>
> /* Check the GUID Partition Table CRC */
> --
> 2.43.0
>
>
More information about the barebox
mailing list