Blame SOURCES/0500-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch

b71686
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b71686
From: Javier Martinez Canillas <javierm@redhat.com>
b71686
Date: Tue, 26 May 2020 16:59:28 +0200
b71686
Subject: [PATCH] x86-efi: Reduce maximum bounce buffer size to 16 MiB
b71686
b71686
The EFI linux loader allocates a bounce buffer to copy the initrd since in
b71686
some machines doing DMA on addresses above 4GB is not possible during EFI.
b71686
b71686
But the verifiers framework also allocates a buffer to copy the initrd in
b71686
its grub_file_open() handler. It does this since the data to verify has to
b71686
be passed as a single chunk to modules that use the verifiers framework.
b71686
b71686
If the initrd image size is big there may not be enough memory in the heap
b71686
to allocate two buffers of that size. This causes an allocation failure in
b71686
the verifiers framework and leads to the initrd not being read.
b71686
b71686
To prevent these allocation failures, let's reduce the maximum size of the
b71686
bounce buffer used in the EFI loader. Since the data read can be copied to
b71686
the actual initrd address in multilple chunks.
b71686
b71686
Resolves: rhbz#1838633
b71686
b71686
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
b71686
(cherry picked from commit 1c0d2ebdddf69962395f0fa4578446654512f3c4)
b71686
---
b71686
 grub-core/loader/i386/efi/linux.c | 2 +-
b71686
 1 file changed, 1 insertion(+), 1 deletion(-)
b71686
b71686
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
b71686
index e9d2c85b3..a043df891 100644
b71686
--- a/grub-core/loader/i386/efi/linux.c
b71686
+++ b/grub-core/loader/i386/efi/linux.c
b71686
@@ -146,7 +146,7 @@ grub_linuxefi_unload (void)
b71686
   return GRUB_ERR_NONE;
b71686
 }
b71686
 
b71686
-#define BOUNCE_BUFFER_MAX 0x10000000ull
b71686
+#define BOUNCE_BUFFER_MAX 0x1000000ull
b71686
 
b71686
 static grub_ssize_t
b71686
 read(grub_file_t file, grub_uint8_t *bufp, grub_size_t len)