[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] This patch fixes the Linux builder so that it dies gracefully when



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 43d141d56c78baf60794d3db9f419fffc6efdccd
# Parent  86d8246c6aff4974d96b9375c3747915bb858a26
This patch fixes the Linux builder so that it dies gracefully when
trying to load malformed ELF images.
Signed-off-by: Aravindh Puthiyaparambil <aravindh.puthiyaparambil@xxxxxxxxxx>
---
 tools/libxc/xc_linux_build.c |    4 +++-
 tools/libxc/xc_load_elf.c    |   11 +++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff -r 86d8246c6aff -r 43d141d56c78 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Wed May 17 23:15:36 2006 +0100
+++ b/tools/libxc/xc_linux_build.c      Wed May 17 23:19:18 2006 +0100
@@ -794,9 +794,11 @@ static int setup_guest(int xc_handle,
         goto error_out;
     }
 
-    (load_funcs.loadimage)(image, image_size,
+    rc = (load_funcs.loadimage)(image, image_size,
                            xc_handle, dom, page_array,
                            &dsi);
+    if ( rc != 0 )
+        goto error_out;
 
     if ( load_initrd(xc_handle, dom, initrd,
                      vinitrd_start - dsi.v_start, page_array) )
diff -r 86d8246c6aff -r 43d141d56c78 tools/libxc/xc_load_elf.c
--- a/tools/libxc/xc_load_elf.c Wed May 17 23:15:36 2006 +0100
+++ b/tools/libxc/xc_load_elf.c Wed May 17 23:19:18 2006 +0100
@@ -151,6 +151,13 @@ static int parseelfimage(const char *ima
     virt_base = 0;
     if ( (p = strstr(guestinfo, "VIRT_BASE=")) != NULL )
         virt_base = strtoul(p+10, &p, 0);
+
+    if ( virt_base == 0 )
+    {
+        ERROR("Malformed ELF image. VIRT_BASE in '__xen_guest' section set 
incorrectly");
+        return -EINVAL;
+    }
+
     dsi->elf_paddr_offset = virt_base;
     if ( (p = strstr(guestinfo, "ELF_PADDR_OFFSET=")) != NULL )
         dsi->elf_paddr_offset = strtoul(p+17, &p, 0);
@@ -219,6 +226,8 @@ loadelfimage(
             pa = (phdr->p_paddr + done) - dsi->elf_paddr_offset;
             va = xc_map_foreign_range(
                 xch, dom, PAGE_SIZE, PROT_WRITE, parray[pa>>PAGE_SHIFT]);
+            if ( va == NULL )
+                return -1;
             chunksz = phdr->p_filesz - done;
             if ( chunksz > (PAGE_SIZE - (pa & (PAGE_SIZE-1))) )
                 chunksz = PAGE_SIZE - (pa & (PAGE_SIZE-1));
@@ -232,6 +241,8 @@ loadelfimage(
             pa = (phdr->p_paddr + done) - dsi->elf_paddr_offset;
             va = xc_map_foreign_range(
                 xch, dom, PAGE_SIZE, PROT_WRITE, parray[pa>>PAGE_SHIFT]);
+            if ( va == NULL )
+                return -1;
             chunksz = phdr->p_memsz - done;
             if ( chunksz > (PAGE_SIZE - (pa & (PAGE_SIZE-1))) )
                 chunksz = PAGE_SIZE - (pa & (PAGE_SIZE-1));

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.