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