File 23505-x86-cpu-add-arg-check.patch of Package xen.import4929

# HG changeset patch
# User Keir Fraser <keir@xen.org>
# Date 1307689724 -3600
# Node ID 5a557fda70a99d287735b53957e865c8dac0e351
# Parent  c34604d5a29336d902837542b915d3b09b27a361
x86: Fix argument checking in (privileged) function cpu_add().

Thanks to John McDermott <john.mcdermott@nrl.navy.mil> for spotting.

Signed-off-by: Keir Fraser <keir@xen.org>

--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -1476,7 +1476,9 @@ int cpu_add(uint32_t apic_id, uint32_t a
 	dprintk(XENLOG_DEBUG, "cpu_add apic_id %x acpi_id %x pxm %x\n",
 		apic_id, acpi_id, pxm);
 
-	if ( acpi_id > MAX_MADT_ENTRIES || apic_id > MAX_APICS || pxm > 256 )
+	if ( (acpi_id >= MAX_MADT_ENTRIES) ||
+	     (apic_id >= MAX_APICS) ||
+	     (pxm >= 256) )
 		return -EINVAL;
 
 	/* Detect if the cpu has been added before */
openSUSE Build Service is sponsored by