ia64/xen-unstable

changeset 9150:9de50910defd

libxc: Verify Magic number when reading dump

The xen core files record a magic number,
but when they are loaded it isn't checked.
This patch resolves this.

Signed-Off-By: Horms <horms@verge.net.au>
author kaf24@firebug.cl.cam.ac.uk
date Mon Mar 06 15:04:18 2006 +0100 (2006-03-06)
parents 0161a721bad5
children 941897e98591
files tools/libxc/xc_core.c tools/libxc/xc_ptrace_core.c tools/libxc/xenctrl.h
line diff
     1.1 --- a/tools/libxc/xc_core.c	Mon Mar 06 15:02:26 2006 +0100
     1.2 +++ b/tools/libxc/xc_core.c	Mon Mar 06 15:04:18 2006 +0100
     1.3 @@ -61,7 +61,7 @@ xc_domain_dumpcore(int xc_handle,
     1.4   
     1.5      nr_pages = info.nr_pages;
     1.6  
     1.7 -    header.xch_magic = 0xF00FEBED; 
     1.8 +    header.xch_magic = XC_CORE_MAGIC;
     1.9      header.xch_nr_vcpus = nr_vcpus;
    1.10      header.xch_nr_pages = nr_pages;
    1.11      header.xch_ctxt_offset = sizeof(struct xc_core_header);
     2.1 --- a/tools/libxc/xc_ptrace_core.c	Mon Mar 06 15:02:26 2006 +0100
     2.2 +++ b/tools/libxc/xc_ptrace_core.c	Mon Mar 06 15:04:18 2006 +0100
     2.3 @@ -111,6 +111,13 @@ xc_waitdomain_core(
     2.4          if (read(domfd, &header, sizeof(header)) != sizeof(header))
     2.5              return -1;
     2.6  
     2.7 +        if (header.xch_magic != XC_CORE_MAGIC) {
     2.8 +                printf("Magic number missmatch: 0x%08x (file) != "
     2.9 +                                        " 0x%08x (code)\n", header.xch_magic,
    2.10 +                                        XC_CORE_MAGIC);
    2.11 +                return -1;
    2.12 +        }
    2.13 +
    2.14          nr_pages = header.xch_nr_pages;
    2.15          nr_vcpus = header.xch_nr_vcpus;
    2.16          pages_offset = header.xch_pages_offset;
     3.1 --- a/tools/libxc/xenctrl.h	Mon Mar 06 15:02:26 2006 +0100
     3.2 +++ b/tools/libxc/xenctrl.h	Mon Mar 06 15:04:18 2006 +0100
     3.3 @@ -92,6 +92,7 @@ typedef struct xc_core_header {
     3.4      unsigned int xch_pages_offset;
     3.5  } xc_core_header_t;
     3.6  
     3.7 +#define XC_CORE_MAGIC 0xF00FEBED
     3.8  
     3.9  long xc_ptrace_core(
    3.10      int xc_handle,