[prev in list] [next in list] [prev in thread] [next in thread]
List: xen-devel
Subject: [Xen-devel] [patch] improve ELF loader error messages
From: Hollis Blanchard <hollisb () us ! ibm ! com>
Date: 2006-06-30 20:42:53
Message-ID: 1151700174.15657.60.camel () basalt ! austin ! ibm ! com
[Download RAW message or body]
Provide more specific and helpful error messages during ELF loading.
Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
diff -r 68928d1c8ab6 tools/libxc/xc_load_elf.c
--- a/tools/libxc/xc_load_elf.c Fri Jun 30 15:24:44 2006 -0500
+++ b/tools/libxc/xc_load_elf.c Fri Jun 30 15:40:09 2006 -0500
@@ -169,8 +169,11 @@ static int parseelfimage(const char *ima
elf_pa_off_defined = (p != NULL);
elf_pa_off = elf_pa_off_defined ? strtoull(p+17, &p, 0) : virt_base;
- if ( elf_pa_off_defined && !virt_base_defined )
- goto bad_image;
+ if ( elf_pa_off_defined && !virt_base_defined ) {
+ ERROR("Neither ELF_PADDR_OFFSET nor VIRT_BASE found in __xen_guest"
+ " section.");
+ return -EINVAL;
+ }
for ( h = 0; h < ehdr->e_phnum; h++ )
{
@@ -178,8 +181,11 @@ static int parseelfimage(const char *ima
if ( !is_loadable_phdr(phdr) )
continue;
vaddr = phdr->p_paddr - elf_pa_off + virt_base;
- if ( (vaddr + phdr->p_memsz) < vaddr )
- goto bad_image;
+ if ( (vaddr + phdr->p_memsz) < vaddr ) {
+ ERROR("ELF program header %d is too large.", h);
+ return -EINVAL;
+ }
+
if ( vaddr < kernstart )
kernstart = vaddr;
if ( (vaddr + phdr->p_memsz) > kernend )
@@ -201,8 +207,10 @@ static int parseelfimage(const char *ima
if ( (kernstart > kernend) ||
(dsi->v_kernentry < kernstart) ||
(dsi->v_kernentry > kernend) ||
- (dsi->v_start > kernstart) )
- goto bad_image;
+ (dsi->v_start > kernstart) ) {
+ ERROR("ELF start or entries are out of bounds.");
+ return -EINVAL;
+ }
if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL )
dsi->load_symtab = 1;
@@ -214,10 +222,6 @@ static int parseelfimage(const char *ima
loadelfsymtab(image, 0, 0, NULL, dsi);
return 0;
-
- bad_image:
- ERROR("Malformed ELF image.");
- return -EINVAL;
}
static int
--
Hollis Blanchard
IBM Linux Technology Center
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic