From 6831d242adf2e90f3e483c323c0b1d0f080790f5 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Wed, 16 Jul 2025 09:06:09 +0100 Subject: [PATCH] loader/efi/linux: Return correct size from LoadFile2 From UEFI specifications 2.10, section 13.2.2, EFI_LOAD_FILE2_PROTOCOL.LoadFile (see https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html), for BufferSize: On input the size of Buffer in bytes. On output with a return code of EFI_SUCCESS, the amount of data transferred to Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL, the size of Buffer required to retrieve the requested file. So, set *buffer_size correctly. Signed-off-by: Frediano Ziglio Reviewed-by: Daniel Kiper --- grub-core/loader/efi/linux.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c index 2c7c874f2..4f5589862 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c @@ -372,6 +372,8 @@ grub_efi_initrd_load_file2 (grub_efi_load_file2_t *this, if (grub_initrd_load (&initrd_ctx, buffer)) status = GRUB_EFI_DEVICE_ERROR; + else + *buffer_size = initrd_size; grub_initrd_close (&initrd_ctx); return status;