mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: Abdelrahman Youssef <abdelrahmanyossef12@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] partitions: efi: Check GPT header size against minimum limit
Date: Wed, 4 Dec 2024 21:18:58 +0300	[thread overview]
Message-ID: <CAP1tNvTf-pKpnO9S_Lo512WscXSVTeA+vxED9eQEtWo0Dof7zg@mail.gmail.com> (raw)
In-Reply-To: <20241204152625.17529-1-abdelrahmanyossef12@gmail.com>

Hello.

Maybe it's better to use sizeof(struct _gpt_header) ?

Thanks!

ср, 4 дек. 2024 г. в 18:30, Abdelrahman Youssef <abdelrahmanyossef12@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@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
>
>



  reply	other threads:[~2024-12-04 18:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-04 15:26 Abdelrahman Youssef
2024-12-04 18:18 ` Alexander Shiyan [this message]
2024-12-06  9:56   ` Sascha Hauer
2024-12-06  9:55 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAP1tNvTf-pKpnO9S_Lo512WscXSVTeA+vxED9eQEtWo0Dof7zg@mail.gmail.com \
    --to=eagle.alexander923@gmail.com \
    --cc=abdelrahmanyossef12@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox