diff options
author | Li Zefan <lizefan@huawei.com> | 2013-03-04 21:57:03 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-03-05 12:33:25 -0500 |
commit | 7d8e0bf56a66bab08d2f316dd87e56c08cecb899 (patch) | |
tree | be35c2daec953f0c98241c16311879dd45bc4859 /include/linux/cgroup.h | |
parent | f50daa704f36a6544a902c52b6cf37b0493dfc5d (diff) |
cgroup: avoid accessing modular cgroup subsys structure without locking
subsys[i] is set to NULL in cgroup_unload_subsys() at modular unload,
and that's protected by cgroup_mutex, and then the memory *subsys[i]
resides will be freed.
So this is unsafe without any locking:
if (!ss || ss->module)
...
v2:
- add a comment for enum cgroup_subsys_id
- simplify the comment in cgroup_exit()
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r-- | include/linux/cgroup.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 75c6ec1ba1ba..5f76829dd75e 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -44,14 +44,25 @@ extern void cgroup_unload_subsys(struct cgroup_subsys *ss); | |||
44 | 44 | ||
45 | extern const struct file_operations proc_cgroup_operations; | 45 | extern const struct file_operations proc_cgroup_operations; |
46 | 46 | ||
47 | /* Define the enumeration of all builtin cgroup subsystems */ | 47 | /* |
48 | * Define the enumeration of all cgroup subsystems. | ||
49 | * | ||
50 | * We define ids for builtin subsystems and then modular ones. | ||
51 | */ | ||
48 | #define SUBSYS(_x) _x ## _subsys_id, | 52 | #define SUBSYS(_x) _x ## _subsys_id, |
49 | #define IS_SUBSYS_ENABLED(option) IS_ENABLED(option) | ||
50 | enum cgroup_subsys_id { | 53 | enum cgroup_subsys_id { |
54 | #define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option) | ||
55 | #include <linux/cgroup_subsys.h> | ||
56 | #undef IS_SUBSYS_ENABLED | ||
57 | CGROUP_BUILTIN_SUBSYS_COUNT, | ||
58 | |||
59 | __CGROUP_SUBSYS_TEMP_PLACEHOLDER = CGROUP_BUILTIN_SUBSYS_COUNT - 1, | ||
60 | |||
61 | #define IS_SUBSYS_ENABLED(option) IS_MODULE(option) | ||
51 | #include <linux/cgroup_subsys.h> | 62 | #include <linux/cgroup_subsys.h> |
63 | #undef IS_SUBSYS_ENABLED | ||
52 | CGROUP_SUBSYS_COUNT, | 64 | CGROUP_SUBSYS_COUNT, |
53 | }; | 65 | }; |
54 | #undef IS_SUBSYS_ENABLED | ||
55 | #undef SUBSYS | 66 | #undef SUBSYS |
56 | 67 | ||
57 | /* Per-subsystem/per-cgroup state maintained by the system. */ | 68 | /* Per-subsystem/per-cgroup state maintained by the system. */ |