Jan Beulich
2009-May-26 12:30 UTC
[Xen-devel] [PATCH] x86/hvm: fix off-by-one errors in vcpuid range checks
Signed-off-by: Jan Beulich <jbeulich@novell.com> --- 2009-05-19.orig/xen/arch/x86/hvm/hvm.c 2009-05-26 12:35:42.000000000 +0200 +++ 2009-05-19/xen/arch/x86/hvm/hvm.c 2009-05-26 12:38:47.000000000 +0200 @@ -503,7 +503,7 @@ static int hvm_load_cpu_ctxt(struct doma /* Which vcpu is this? */ vcpuid = hvm_load_instance(h); - if ( vcpuid > MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL ) + if ( vcpuid >= MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL ) { gdprintk(XENLOG_ERR, "HVM restore: domain has no vcpu %u\n", vcpuid); return -EINVAL; --- 2009-05-19.orig/xen/arch/x86/hvm/mtrr.c 2009-05-26 12:35:42.000000000 +0200 +++ 2009-05-19/xen/arch/x86/hvm/mtrr.c 2009-05-26 12:39:13.000000000 +0200 @@ -676,7 +676,7 @@ static int hvm_load_mtrr_msr(struct doma struct hvm_hw_mtrr hw_mtrr; vcpuid = hvm_load_instance(h); - if ( vcpuid > MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL ) + if ( vcpuid >= MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL ) { gdprintk(XENLOG_ERR, "HVM restore: domain has no vcpu %u\n", vcpuid); return -EINVAL; --- 2009-05-19.orig/xen/arch/x86/hvm/vlapic.c 2009-05-26 12:35:42.000000000 +0200 +++ 2009-05-19/xen/arch/x86/hvm/vlapic.c 2009-05-26 12:39:26.000000000 +0200 @@ -913,7 +913,7 @@ static int lapic_load_hidden(struct doma /* Which vlapic to load? */ vcpuid = hvm_load_instance(h); - if ( vcpuid > MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL ) + if ( vcpuid >= MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL ) { gdprintk(XENLOG_ERR, "HVM restore: domain has no vlapic %u\n", vcpuid); return -EINVAL; @@ -936,7 +936,7 @@ static int lapic_load_regs(struct domain /* Which vlapic to load? */ vcpuid = hvm_load_instance(h); - if ( vcpuid > MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL ) + if ( vcpuid >= MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL ) { gdprintk(XENLOG_ERR, "HVM restore: domain has no vlapic %u\n", vcpuid); return -EINVAL; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel