[PATCH] sched domain sysctl: register online cpus

From: Milton Miller
Date: Fri Oct 12 2007 - 05:36:23 EST


init_sched_domain_sysctl was walking cpus 0-n and referencing per_cpu
variables. If the cpus_possible mask is not contigious this will result
in a crash referencing unallocated data. If the online mask is not
contigious then we would show offline cpus and miss online ones.

Signed-off-by: Milton Miller <miltonm@xxxxxxx>

Index: kernel/kernel/sched.c
===================================================================
--- kernel.orig/kernel/sched.c 2007-10-11 23:48:10.000000000 -0500
+++ kernel/kernel/sched.c 2007-10-11 23:55:51.000000000 -0500
@@ -5367,11 +5367,12 @@ static void init_sched_domain_sysctl(voi

sd_ctl_dir[0].child = entry;

- for (i = 0; i < cpu_num; i++, entry++) {
+ for_each_online_cpu(i) {
snprintf(buf, 32, "cpu%d", i);
entry->procname = kstrdup(buf, GFP_KERNEL);
entry->mode = 0555;
entry->child = sd_alloc_ctl_cpu_table(i);
+ entry++;
}
sd_sysctl_header = register_sysctl_table(sd_ctl_root);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/