sched/debug: Fix sd->*_idx limit range avoiding overflow
authorlibin <huawei.libin@huawei.com>
Mon, 8 Apr 2013 06:39:12 +0000 (14:39 +0800)
committerIngo Molnar <mingo@kernel.org>
Mon, 8 Apr 2013 11:23:03 +0000 (13:23 +0200)
Commit 201c373e8e ("sched/debug: Limit sd->*_idx range on
sysctl") was an incomplete bug fix.

This patch fixes sd->*_idx limit range to [0 ~ CPU_LOAD_IDX_MAX-1]
avoiding array overflow caused by setting sd->*_idx to CPU_LOAD_IDX_MAX
on sysctl.

Signed-off-by: Libin <huawei.libin@huawei.com>
Cc: <jiang.liu@huawei.com>
Cc: <guohanjun@huawei.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/51626610.2040607@huawei.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/core.c

index 306943f531a3e175ecf9595b50e1a76ff225fe44..fa077929e3154bb3a82eb4a227978bab2ef7b5c2 100644 (file)
@@ -4933,7 +4933,7 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
 }
 
 static int min_load_idx = 0;
-static int max_load_idx = CPU_LOAD_IDX_MAX;
+static int max_load_idx = CPU_LOAD_IDX_MAX-1;
 
 static void
 set_table_entry(struct ctl_table *entry,