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

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