Re: [PATCH] grub-mkimage: Add SBAT metadata check

2025-12-20 Thread Sudhakar Kuppusamy


> On 20 Dec 2025, at 7:50 PM, Daniel Kiper  wrote:
> 
> On Fri, Dec 19, 2025 at 03:32:18PM +0530, Sudhakar Kuppusamy wrote:
>> The grub-mkimage does not check if the SBAT metadata file is empty or not 
>> when
>> creating core image with the SBAT metadata file. It leads to adding the 
>> empty SBAT
>> ELF note for PowerPC and the .sbat section for EFI. Fixing this by checking 
>> the
>> SBAT metadata file size before adding it to the ELF note or .sbat section.
>> 
>> Signed-off-by: Sudhakar Kuppusamy 
>> ---
>> util/mkimage.c | 9 +++--
>> 1 file changed, 7 insertions(+), 2 deletions(-)
>> 
>> diff --git a/util/mkimage.c b/util/mkimage.c
>> index f364a5718..7ca580e98 100644
>> --- a/util/mkimage.c
>> +++ b/util/mkimage.c
>> @@ -963,6 +963,12 @@ grub_install_generate_image (const char *dir, const 
>> char *prefix,
>> 
>>   if (sbat_path != NULL && (image_target->id != IMAGE_EFI && 
>> image_target->id != IMAGE_PPC))
>> grub_util_error (_("SBAT data can be added only to EFI or 
>> powerpc-ieee1275 images"));
>> +  else if (sbat_path != NULL)
>> +{
>> +  sbat_size = grub_util_get_image_size (sbat_path);
>> +  if (!sbat_size)
> 
> I think it is not fully correct. SBAT should contain at least header.

Yes, you are correct.

Thank you Daniel. I will correct it on v1

Thanks,
Sudhakar

> 
> Daniel



___
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] grub-mkimage: Add SBAT metadata check

2025-12-20 Thread Daniel Kiper
On Fri, Dec 19, 2025 at 03:32:18PM +0530, Sudhakar Kuppusamy wrote:
> The grub-mkimage does not check if the SBAT metadata file is empty or not when
> creating core image with the SBAT metadata file. It leads to adding the empty 
> SBAT
> ELF note for PowerPC and the .sbat section for EFI. Fixing this by checking 
> the
> SBAT metadata file size before adding it to the ELF note or .sbat section.
>
> Signed-off-by: Sudhakar Kuppusamy 
> ---
>  util/mkimage.c | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/util/mkimage.c b/util/mkimage.c
> index f364a5718..7ca580e98 100644
> --- a/util/mkimage.c
> +++ b/util/mkimage.c
> @@ -963,6 +963,12 @@ grub_install_generate_image (const char *dir, const char 
> *prefix,
>
>if (sbat_path != NULL && (image_target->id != IMAGE_EFI && 
> image_target->id != IMAGE_PPC))
>  grub_util_error (_("SBAT data can be added only to EFI or 
> powerpc-ieee1275 images"));
> +  else if (sbat_path != NULL)
> +{
> +  sbat_size = grub_util_get_image_size (sbat_path);
> +  if (!sbat_size)

I think it is not fully correct. SBAT should contain at least header.

Daniel

___
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel