dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0227-efi-chainloader-fix-wrong-sanity-check-in-relocate_c.patch

4fe85b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4fe85b
From: Laszlo Ersek <lersek@redhat.com>
4fe85b
Date: Mon, 21 Nov 2016 15:34:00 +0100
4fe85b
Subject: [PATCH] efi/chainloader: fix wrong sanity check in relocate_coff()
4fe85b
4fe85b
In relocate_coff(), the relocation entries are parsed from the original
4fe85b
image (not the section-wise copied image). The original image is
4fe85b
pointed-to by the "orig" pointer. The current check
4fe85b
4fe85b
  (void *)reloc_end < data
4fe85b
4fe85b
compares the addresses of independent memory allocations. "data" is a typo
4fe85b
here, it should be "orig".
4fe85b
4fe85b
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1347291
4fe85b
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
4fe85b
Tested-by: Bogdan Costescu <bcostescu@gmail.com>
4fe85b
Tested-by: Juan Orti <j.orti.alcaine@gmail.com>
4fe85b
---
4fe85b
 grub-core/loader/efi/chainloader.c | 2 +-
4fe85b
 1 file changed, 1 insertion(+), 1 deletion(-)
4fe85b
4fe85b
diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
4fe85b
index 3e89de9006c..ed8c364789a 100644
4fe85b
--- a/grub-core/loader/efi/chainloader.c
4fe85b
+++ b/grub-core/loader/efi/chainloader.c
4fe85b
@@ -401,7 +401,7 @@ relocate_coff (pe_coff_loader_image_context_t *context,
4fe85b
       reloc_end = (struct grub_pe32_fixup_block *)
4fe85b
 	((char *)reloc_base + reloc_base->size);
4fe85b
 
4fe85b
-      if ((void *)reloc_end < data || (void *)reloc_end > image_end)
4fe85b
+      if ((void *)reloc_end < orig || (void *)reloc_end > image_end)
4fe85b
         {
4fe85b
           grub_error (GRUB_ERR_BAD_ARGUMENT, "Reloc entry %d overflows binary",
4fe85b
 		      n);