[PATCH] efi_loader: efi_allocate_pages: check parameter pages

Peng Fan (OSS) peng.fan at oss.nxp.com
Thu Feb 16 11:53:21 CET 2023


From: Peng Fan <peng.fan at nxp.com>

On i.MX8MM-EVK, when doing UEFI Capsule On Disk, we met such issue,
It will create Boot option for capsule on disk:
Boot0000: VenHw(E61D73B9-A384-4ACC-AEAB-82E828F3628B)/eMMC(0x2)/eMMC(0x1)/HD(1,GPT,F5CC8412-CD9F-4C9E-A782-0E945461E89E,0x800,0x32000)
But when capsule update finished, the updated image booting will trigger:
Loading Boot0000 'UEFI Capsule On Disk' failed
EFI boot manager: Cannot load any image
Found EFI removable media binary efi/boot/bootaa64.efi
"Synchronous Abort" handler, esr 0x96000004
elr: 000000004029f40c lr : 00000000402802f0 (reloc)
elr: 00000000bcd8b40c lr : 00000000bcd6c2f0
x0 : 02029ee86154940e x1 : 00000000bcd95458
x2 : 0000000000000010 x3 : 00000000bad31ad0
x4 : 0000000000000000 x5 : 02029ee86154940e
x6 : 0000000007f00000 x7 : 0000000000000007
x8 : 0000000000000009 x9 : 0000000000000008
x10: 0000000000000035 x11: 0000000000000010
x12: 0000000000000022 x13: 0000000000000001
x14: 00000000bacdedf0 x15: 0000000000000021
x16: 00000000bcd304d0 x17: 00000000000041a0
x18: 00000000bacebdb0 x19: 00000000b9c9f040
x20: 00000000bccecb28 x21: 00000000bcd95458
x22: 0000000000000001 x23: 00000000bad1f010
x24: 00000000bcdced70 x25: 0000000000001000
x26: 00000000b9c9e000 x27: 0000000040000000
x28: 0000000000000001 x29: 00000000bacdd030

If is the pages is 0, the efi_find_free_memory will return the next used
memory, check the parameter pages, and return EFI_INVALID_PARAMETER if it
is 0.

Reviewed-by: Ye Li <ye.li at nxp.com>
Reported-by: Vincent Stehlé <vincent.stehle at arm.com>
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
 lib/efi_loader/efi_memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index b7bee98f79c..acca542033d 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -495,6 +495,9 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type,
 	if (!memory)
 		return EFI_INVALID_PARAMETER;
 
+	if (!pages)
+		return EFI_INVALID_PARAMETER;
+
 	switch (type) {
 	case EFI_ALLOCATE_ANY_PAGES:
 		/* Any page */
-- 
2.36.0



More information about the U-Boot mailing list