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

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