efi_loader: correct parameter size in efi_allocate_pool
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 18 Mar 2019 19:01:59 +0000 (20:01 +0100)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Wed, 20 Mar 2019 17:16:53 +0000 (18:16 +0100)
efi_allocate_pages() expects a (uint64_t *) pointer to pass the address of
the assigned memory. If we pass the address of a pointer here, an illegal
memory access occurs on 32bit systems.

Fixes: 282a06cbcae8 ("efi_loader: Expose U-Boot addresses in memory map
for sandbox")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_loader/efi_memory.c

index ebd2b36c03d7042700ea3a21ffa9155ef06f4fc8..55622d2fb40178652c57b8c57d5945259bf6a922 100644 (file)
@@ -440,6 +440,7 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages)
 efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer)
 {
        efi_status_t r;
+       u64 addr;
        struct efi_pool_allocation *alloc;
        u64 num_pages = efi_size_in_pages(size +
                                          sizeof(struct efi_pool_allocation));
@@ -453,9 +454,9 @@ efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer)
        }
 
        r = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, pool_type, num_pages,
-                              (uint64_t *)&alloc);
-
+                              &addr);
        if (r == EFI_SUCCESS) {
+               alloc = (struct efi_pool_allocation *)(uintptr_t)addr;
                alloc->num_pages = num_pages;
                *buffer = alloc->data;
        }