* grub-core/loader/multiboot_elfxx.c: Check eip after v2p translation

and not before.
	Reported by: Leon Drugi.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-07-16 18:37:44 +02:00
parent 3f42504c15
commit 88f8d1463f
2 changed files with 19 additions and 12 deletions

View File

@ -1,3 +1,9 @@
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.

View File

@ -75,18 +75,6 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi
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))
@ -142,6 +130,19 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi
{
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;
}