ia64/xen-unstable

changeset 19653:b671d568115f

x86/hvm: fix off-by-one errors in vcpuid range checks

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed May 27 11:17:40 2009 +0100 (2009-05-27)
parents 7dfc0a20fa59
children 11b3b6fafc7b
files xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/mtrr.c xen/arch/x86/hvm/vlapic.c
line diff
     1.1 --- a/xen/arch/x86/hvm/hvm.c	Wed May 27 11:16:27 2009 +0100
     1.2 +++ b/xen/arch/x86/hvm/hvm.c	Wed May 27 11:17:40 2009 +0100
     1.3 @@ -503,7 +503,7 @@ static int hvm_load_cpu_ctxt(struct doma
     1.4  
     1.5      /* Which vcpu is this? */
     1.6      vcpuid = hvm_load_instance(h);
     1.7 -    if ( vcpuid > MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL ) 
     1.8 +    if ( vcpuid >= MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL )
     1.9      {
    1.10          gdprintk(XENLOG_ERR, "HVM restore: domain has no vcpu %u\n", vcpuid);
    1.11          return -EINVAL;
     2.1 --- a/xen/arch/x86/hvm/mtrr.c	Wed May 27 11:16:27 2009 +0100
     2.2 +++ b/xen/arch/x86/hvm/mtrr.c	Wed May 27 11:17:40 2009 +0100
     2.3 @@ -676,7 +676,7 @@ static int hvm_load_mtrr_msr(struct doma
     2.4      struct hvm_hw_mtrr hw_mtrr;
     2.5  
     2.6      vcpuid = hvm_load_instance(h);
     2.7 -    if ( vcpuid > MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL )
     2.8 +    if ( vcpuid >= MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL )
     2.9      {
    2.10          gdprintk(XENLOG_ERR, "HVM restore: domain has no vcpu %u\n", vcpuid);
    2.11          return -EINVAL;
     3.1 --- a/xen/arch/x86/hvm/vlapic.c	Wed May 27 11:16:27 2009 +0100
     3.2 +++ b/xen/arch/x86/hvm/vlapic.c	Wed May 27 11:17:40 2009 +0100
     3.3 @@ -913,7 +913,7 @@ static int lapic_load_hidden(struct doma
     3.4      
     3.5      /* Which vlapic to load? */
     3.6      vcpuid = hvm_load_instance(h); 
     3.7 -    if ( vcpuid > MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL ) 
     3.8 +    if ( vcpuid >= MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL )
     3.9      {
    3.10          gdprintk(XENLOG_ERR, "HVM restore: domain has no vlapic %u\n", vcpuid);
    3.11          return -EINVAL;
    3.12 @@ -936,7 +936,7 @@ static int lapic_load_regs(struct domain
    3.13      
    3.14      /* Which vlapic to load? */
    3.15      vcpuid = hvm_load_instance(h); 
    3.16 -    if ( vcpuid > MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL ) 
    3.17 +    if ( vcpuid >= MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL )
    3.18      {
    3.19          gdprintk(XENLOG_ERR, "HVM restore: domain has no vlapic %u\n", vcpuid);
    3.20          return -EINVAL;