summaryrefslogtreecommitdiff
path: root/sys/arch/i386
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/i386
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/i386')
-rw-r--r--sys/arch/i386/i386/cpu.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/arch/i386/i386/cpu.c b/sys/arch/i386/i386/cpu.c
index 8a9898b08a8..c2d628e9a40 100644
--- a/sys/arch/i386/i386/cpu.c
+++ b/sys/arch/i386/i386/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.41 2010/07/25 21:43:35 deraadt Exp $ */
+/* $OpenBSD: cpu.c,v 1.42 2010/11/27 13:03:04 kettenis Exp $ */
/* $NetBSD: cpu.c,v 1.1.2.7 2000/06/26 02:04:05 sommerfeld Exp $ */
/*-
@@ -157,14 +157,18 @@ struct cfdriver cpu_cd = {
};
int
-cpu_match(struct device *parent, void *matchv, void *aux)
+cpu_match(struct device *parent, void *match, void *aux)
{
- struct cfdata *match = (struct cfdata *)matchv;
- struct cpu_attach_args *caa = (struct cpu_attach_args *)aux;
+ struct cfdata *cf = match;
+ struct cpu_attach_args *caa = aux;
- if (strcmp(caa->caa_name, match->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;
}
void