mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] partitions: efi: Check GPT header size against minimum limit
@ 2024-12-04 15:26 Abdelrahman Youssef
  2024-12-04 18:18 ` Alexander Shiyan
  2024-12-06  9:55 ` Sascha Hauer
  0 siblings, 2 replies; 4+ messages in thread
From: Abdelrahman Youssef @ 2024-12-04 15:26 UTC (permalink / raw)
  To: barebox; +Cc: Abdelrahman Youssef

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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] partitions: efi: Check GPT header size against minimum limit
  2024-12-04 15:26 [PATCH] partitions: efi: Check GPT header size against minimum limit Abdelrahman Youssef
@ 2024-12-04 18:18 ` Alexander Shiyan
  2024-12-06  9:56   ` Sascha Hauer
  2024-12-06  9:55 ` Sascha Hauer
  1 sibling, 1 reply; 4+ messages in thread
From: Alexander Shiyan @ 2024-12-04 18:18 UTC (permalink / raw)
  To: Abdelrahman Youssef; +Cc: barebox

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
>
>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] partitions: efi: Check GPT header size against minimum limit
  2024-12-04 15:26 [PATCH] partitions: efi: Check GPT header size against minimum limit Abdelrahman Youssef
  2024-12-04 18:18 ` Alexander Shiyan
@ 2024-12-06  9:55 ` Sascha Hauer
  1 sibling, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-12-06  9:55 UTC (permalink / raw)
  To: barebox, Abdelrahman Youssef


On Wed, 04 Dec 2024 17:26:25 +0200, Abdelrahman Youssef wrote:
> 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
> 
> [...]

Applied, thanks!

[1/1] partitions: efi: Check GPT header size against minimum limit
      https://git.pengutronix.de/cgit/barebox/commit/?id=73f0aaa3c544 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] partitions: efi: Check GPT header size against minimum limit
  2024-12-04 18:18 ` Alexander Shiyan
@ 2024-12-06  9:56   ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-12-06  9:56 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: Abdelrahman Youssef, barebox

On Wed, Dec 04, 2024 at 09:18:58PM +0300, Alexander Shiyan wrote:
> Hello.
> 
> Maybe it's better to use sizeof(struct _gpt_header) ?

Changed to use sizeof while applying

Sascha

> 
> 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
> >
> >
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-06  9:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-04 15:26 [PATCH] partitions: efi: Check GPT header size against minimum limit Abdelrahman Youssef
2024-12-04 18:18 ` Alexander Shiyan
2024-12-06  9:56   ` Sascha Hauer
2024-12-06  9:55 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox