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

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