+2013-07-16 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/loader/multiboot_elfxx.c: Check eip after v2p translation
+ and not before.
+ Reported by: Leon Drugi.
+
2013-07-16 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/powerpc/ieee1275/startup.S: Handle unaligned bss.
if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH)
return grub_error (GRUB_ERR_BAD_OS, "program header at a too high offset");
-#ifdef MULTIBOOT_LOAD_ELF64
-# ifdef __mips
- /* We still in 32-bit mode. */
- if (ehdr->e_entry < 0xffffffff80000000ULL)
- return grub_error (GRUB_ERR_BAD_OS, "invalid entry point for ELF64");
-# else
- /* We still in 32-bit mode. */
- if (ehdr->e_entry > 0xffffffff)
- return grub_error (GRUB_ERR_BAD_OS, "invalid entry point for ELF64");
-# endif
-#endif
-
phdr_base = (char *) buffer + ehdr->e_phoff;
#define phdr(i) ((Elf_Phdr *) (phdr_base + (i) * ehdr->e_phentsize))
{
grub_multiboot_payload_eip = (ehdr->e_entry - phdr(i)->p_vaddr)
+ phdr(i)->p_paddr;
+#ifdef MULTIBOOT_LOAD_ELF64
+# ifdef __mips
+ /* We still in 32-bit mode. */
+ if ((ehdr->e_entry - phdr(i)->p_vaddr)
+ + phdr(i)->p_paddr < 0xffffffff80000000ULL)
+ return grub_error (GRUB_ERR_BAD_OS, "invalid entry point for ELF64");
+# else
+ /* We still in 32-bit mode. */
+ if ((ehdr->e_entry - phdr(i)->p_vaddr)
+ + phdr(i)->p_paddr > 0xffffffff)
+ return grub_error (GRUB_ERR_BAD_OS, "invalid entry point for ELF64");
+# endif
+#endif
break;
}