summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2010-11-27 13:03:05 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2010-11-27 13:03:05 +0000
commita7e72a26d7878ba0e8ff26bbb5434d9b22505c66 (patch)
treec2abd8e1a5730b2f3f236daa3fbe7a58155b9fc0 /sys/arch/amd64
parente35197f73309dc98fa8e783eb1cf5246a62b3a97 (diff)
Make sure we don't attach more CPUs than we can handle. Prevents an
out-of-bounds array access later on. Allows OpenBSD to boot on machines with more than 32 CPUs/cores. ok krw@, jsing@, dlg@
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/amd64/cpu.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c
index 2089a1a5b7c..2f98f6c4888 100644
--- a/sys/arch/amd64/amd64/cpu.c
+++ b/sys/arch/amd64/amd64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.39 2010/11/26 11:59:40 krw Exp $ */
+/* $OpenBSD: cpu.c,v 1.40 2010/11/27 13:03:04 kettenis Exp $ */
/* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */
/*-
@@ -166,9 +166,13 @@ cpu_match(struct device *parent, void *match, void *aux)
struct cfdata *cf = match;
struct cpu_attach_args *caa = aux;
- if (strcmp(caa->caa_name, cf->cf_driver->cd_name) == 0)
- return 1;
- return 0;
+ if (strcmp(caa->caa_name, cf->cf_driver->cd_name) != 0)
+ return 0;
+
+ if (cf->cf_unit >= MAXCPUS)
+ return 0;
+
+ return 1;
}
static void