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

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