nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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