[IA64] Avoid array overflow if there are too many cpus in SRAT table
authorTony Luck <tony.luck@intel.com>
Fri, 7 Jan 2011 17:11:55 +0000 (09:11 -0800)
committerTony Luck <tony.luck@intel.com>
Fri, 7 Jan 2011 17:11:55 +0000 (09:11 -0800)
acpi_numa_init() has to parse the whole SRAT table, even if the
kernel wants to limit the number of cpus it will use (because the
ones it is going to use may be described by entries at the end of
the SRAT table).  Avoid overflowing the node_cpuid array.

Reported-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
arch/ia64/kernel/acpi.c

index c6c90f39f4d9e35381cedf30cbd700fd4d7c84cb..7b897b7b0ae6222ca5b5e9ef5d6039f122c87814 100644 (file)
@@ -477,6 +477,12 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
        if (!(pa->flags & ACPI_SRAT_CPU_ENABLED))
                return;
 
+       if (srat_num_cpus >= ARRAY_SIZE(node_cpuid)) {
+               printk_once(KERN_WARNING
+                           "node_cpuid[%d] is too small, may not be able to use all cpus\n",
+                           ARRAY_SIZE(node_cpuid));
+               return;
+       }
        pxm = get_processor_proximity_domain(pa);
 
        /* record this node in proximity bitmap */