Blame SOURCES/0275-x86-efi-Fix-an-incorrect-array-size-in-kernel-alloca.patch

b35c50
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b35c50
From: Peter Jones <pjones@redhat.com>
b35c50
Date: Tue, 11 Oct 2022 17:00:50 -0400
b35c50
Subject: [PATCH] x86-efi: Fix an incorrect array size in kernel allocation
b35c50
b35c50
In 81a6ebf62bbe166ddc968463df2e8bd481bf697c ("efi: split allocation
b35c50
policy for kernel vs initrd memories."), I introduced a split in the
b35c50
kernel allocator to allow for different dynamic policies for the kernel
b35c50
and the initrd allocations.
b35c50
b35c50
Unfortunately, that change increased the size of the policy data used to
b35c50
make decisions, but did not change the size of the temporary storage we
b35c50
use to back it up and restore.  This results in some of .data getting
b35c50
clobbered at runtime, and hilarity ensues.
b35c50
b35c50
This patch makes the size of the backup storage be based on the size of
b35c50
the initial policy data.
b35c50
b35c50
Signed-off-by: Peter Jones <pjones@redhat.com>
b35c50
---
b35c50
 grub-core/loader/i386/efi/linux.c | 2 +-
b35c50
 1 file changed, 1 insertion(+), 1 deletion(-)
b35c50
b35c50
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
b35c50
index ac5ef50bdb..9854b0defa 100644
b35c50
--- a/grub-core/loader/i386/efi/linux.c
b35c50
+++ b/grub-core/loader/i386/efi/linux.c
b35c50
@@ -92,7 +92,7 @@ static struct allocation_choice max_addresses[] =
b35c50
       { INITRD_MEM, GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS },
b35c50
     { NO_MEM, 0, 0 }
b35c50
   };
b35c50
-static struct allocation_choice saved_addresses[4];
b35c50
+static struct allocation_choice saved_addresses[sizeof(max_addresses) / sizeof(max_addresses[0])];
b35c50
 
b35c50
 #define save_addresses() grub_memcpy(saved_addresses, max_addresses, sizeof(max_addresses))
b35c50
 #define restore_addresses() grub_memcpy(max_addresses, saved_addresses, sizeof(max_addresses))