ia64/xen-unstable

changeset 15415:38d061886873

[IA64] Fix incorrect NVRAM saving if domain is destroyed by config error

Nvram saving is always executed even if a domain is destroyed by a
configuration parameter error. In this case, Nvram saving function
will get a bad address for the NVRAM data and save garbage into the
NVRAM file. Configuring a wrong vif parameter can expose this issue.

This patch fixes the issue by adding an address check function in
NVRAM saving path.

Signed-off-by: Zhang Xin <xing.z.zhang@intel.com>
author Alex Williamson <alex.williamson@hp.com>
date Mon Jul 02 09:05:24 2007 -0600 (2007-07-02)
parents 89596982890b
children 88ab11d8fd1c
files tools/libxc/ia64/xc_ia64_hvm_build.c xen/include/public/arch-ia64.h
line diff
     1.1 --- a/tools/libxc/ia64/xc_ia64_hvm_build.c	Mon Jul 02 08:51:59 2007 -0600
     1.2 +++ b/tools/libxc/ia64/xc_ia64_hvm_build.c	Mon Jul 02 09:05:24 2007 -0600
     1.3 @@ -623,6 +623,21 @@ copy_from_nvram_to_GFW(int xc_handle, ui
     1.4  
     1.5  
     1.6  /*
     1.7 + *Check is the address where NVRAM data located valid
     1.8 + */
     1.9 +static int is_valid_address(void *addr)
    1.10 +{
    1.11 +    struct nvram_save_addr *p = (struct nvram_save_addr *)addr;	
    1.12 +
    1.13 +    if ( p->signature == NVRAM_VALID_SIG )
    1.14 +        return 1;
    1.15 +    else {
    1.16 +        PERROR("Invalid nvram signature. Nvram save failed!\n");
    1.17 +        return 0;
    1.18 +    }
    1.19 +}
    1.20 +
    1.21 +/*
    1.22   * GFW use 4k page. when doing foreign map, we should 16k align
    1.23   * the address and map one more page to guarantee all 64k nvram data 
    1.24   * can be got.
    1.25 @@ -667,7 +682,11 @@ copy_from_GFW_to_nvram(int xc_handle, ui
    1.26          return -1;
    1.27      }
    1.28  
    1.29 -    addr_from_GFW_4k_align = *((uint64_t *)tmp_ptr);
    1.30 +    /* Check is NVRAM data vaild */
    1.31 +    if ( !is_valid_address(tmp_ptr) )
    1.32 +        return -1;
    1.33 +
    1.34 +    addr_from_GFW_4k_align = ((struct nvram_save_addr *)tmp_ptr)->addr;
    1.35      munmap(tmp_ptr, PAGE_SIZE);
    1.36  
    1.37      // align address to 16k
     2.1 --- a/xen/include/public/arch-ia64.h	Mon Jul 02 08:51:59 2007 -0600
     2.2 +++ b/xen/include/public/arch-ia64.h	Mon Jul 02 09:05:24 2007 -0600
     2.3 @@ -117,6 +117,12 @@ typedef unsigned long xen_ulong_t;
     2.4  #define NVRAM_SIZE       (MEM_K * 64)
     2.5  #define NVRAM_START      (GFW_START + 10 * MEM_M)
     2.6  
     2.7 +#define NVRAM_VALID_SIG 0x4650494e45584948 		// "HIXENIPF"
     2.8 +struct nvram_save_addr {
     2.9 +    unsigned long addr;
    2.10 +    unsigned long signature;
    2.11 +};
    2.12 +
    2.13  struct pt_fpreg {
    2.14      union {
    2.15          unsigned long bits[2];