[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen stable-4.20] EFI: refine cfgfile buffer allocation



commit 74cdd4423ca887940b469bd01b49ea8be237f49b
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Oct 29 13:31:27 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Oct 29 13:31:27 2026 +0100

    EFI: refine cfgfile buffer allocation
    
    Use of AllocateMaxAddress requires that the variable pointed to by the
    last argument of ->AllocatePages() is initialized. For cfgfile buffers we
    don't need AllocateMaxAddress though, at which point initialization of
    "addr" also isn't necessary anymore.
    
    Mirror the lack of address constraint also to the main / central buffer
    allocation in read_file().
    
    Fixes: df75f77092c1 ("EFI: avoid OOB config file reads")
    Assisted-by: Sashiko + Opus 5.0
    Reported-by: George Dunlap <dunlapg@xxxxxxxxx>
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
    master commit: cf76c4b8c79ffacbb171468900a7da7d0b1693dc
    master date: 2026-10-06 08:14:43 +0200
---
 xen/common/efi/boot.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 5082a23a7f..b63ad8aa6b 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -783,8 +783,13 @@ static bool __init read_file(EFI_FILE_HANDLE dir_handle, 
CHAR16 *name,
     {
         file->addr = min(1UL << (32 + PAGE_SHIFT),
                          HYPERVISOR_VIRT_END - DIRECTMAP_VIRT_START);
-        /* For config files allocate an extra byte to put a NUL there. */
-        ret = efi_bs->AllocatePages(AllocateMaxAddress, EfiLoaderData,
+        /*
+         * For config files allocate an extra byte to put a NUL there.  There's
+         * also no constraint on addresses for them.
+         */
+        ret = efi_bs->AllocatePages(file != &cfg ? AllocateMaxAddress
+                                                 : AllocateAnyPages,
+                                    EfiLoaderData,
                                     PFN_UP(size + (file == &cfg)), 
&file->addr);
     }
     if ( EFI_ERROR(ret) )
@@ -836,7 +841,7 @@ static bool __init read_section(const EFI_LOADED_IMAGE 
*image,
     if ( file == &cfg && file->size && !iscntrl(file->str[file->size - 1]) )
     {
         EFI_PHYSICAL_ADDRESS addr;
-        EFI_STATUS ret = efi_bs->AllocatePages(AllocateMaxAddress,
+        EFI_STATUS ret = efi_bs->AllocatePages(AllocateAnyPages,
                                                EfiLoaderData,
                                                PFN_UP(file->size + 1), &addr);
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.20



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.