cgroup: add a validation check to cgroup_add_cftyps()
authorLi Zefan <lizefan@huawei.com>
Mon, 17 Feb 2014 02:41:50 +0000 (10:41 +0800)
committerTejun Heo <tj@kernel.org>
Tue, 18 Feb 2014 23:20:09 +0000 (18:20 -0500)
commitdc5736ed7aaf942caaac0c15af74a018e04ec79d
tree173eb94ee590ef0ba1ab295a49304a0fd1f8a4c2
parentcc045e3952175e84c38dad22dea14465b9fc8fb5
cgroup: add a validation check to cgroup_add_cftyps()

Fengguang reported this bug:

BUG: unable to handle kernel NULL pointer dereference at 0000003c
IP: [<cc90b4ad>] cgroup_cfts_commit+0x27/0x1c1
...
Call Trace:
  [<cc9d1129>] ? kmem_cache_alloc_trace+0x33f/0x3b7
  [<cc90c6fc>] cgroup_add_cftypes+0x8f/0xca
  [<cd78b646>] cgroup_init+0x6a/0x26a
  [<cd764d7d>] start_kernel+0x4d7/0x57a
  [<cd7642ef>] i386_start_kernel+0x92/0x96

This happens in a corner case. If CGROUP_SCHED=y but CFS_BANDWIDTH=n &&
FAIR_GROUP_SCHED=n && RT_GROUP_SCHED=n, we have:

cpu_files[] = {
{ } /* terminate */
}

When we pass cpu_files to cgroup_apply_cftypes(), as cpu_files[0].ss
is NULL, we'll access NULL pointer.

The bug was introduced by commit de00ffa56ea3132c6013fc8f07133b8a1014cf53
("cgroup: make cgroup_subsys->base_cftypes use cgroup_add_cftypes()").

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup.c
This page took 0.024667 seconds and 5 git commands to generate.