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

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