aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2014-05-13 12:10:59 -0400
committerTejun Heo <tj@kernel.org>2014-05-13 12:10:59 -0400
commitd37167ab7b3d67d53519585a44c47416e6758ed2 (patch)
treeedd7be2be5f5b4131d29eb52c0ee932a7a8e7298 /kernel/cgroup.c
parent0ab7a60dea71c285dfbb65e344d895b9c4f7bcb9 (diff)
cgroup: update and fix parsing of "cgroup.subtree_control"
I was confused that strsep() was equivalent to strtok_r() in skipping over consecutive delimiters. strsep() just splits at the first occurrence of one of the delimiters which makes the parsing very inflexible, which makes allowing multiple whitespace chars as delimters kinda moot. Let's just be consistently strict and require list of tokens separated by spaces. This is what Documentation/cgroups/unified-hierarchy.txt describes too. Also, parsing may access beyond the end of the string if the string ends with spaces or is zero-length. Make sure it skips zero-length tokens. Note that this also ensures that the parser doesn't puke on multiple consecutive spaces. v2: Add zero-length token skipping. v3: Added missing space after "==". Spotted by Li. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 35daf892b6e6..250def0694b4 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2542,11 +2542,13 @@ static int cgroup_subtree_control_write(struct cgroup_subsys_state *dummy_css,
2542 int ssid, ret; 2542 int ssid, ret;
2543 2543
2544 /* 2544 /*
2545 * Parse input - white space separated list of subsystem names 2545 * Parse input - space separated list of subsystem names prefixed
2546 * prefixed with either + or -. 2546 * with either + or -.
2547 */ 2547 */
2548 p = buffer; 2548 p = buffer;
2549 while ((tok = strsep(&p, " \t\n"))) { 2549 while ((tok = strsep(&p, " "))) {
2550 if (tok[0] == '\0')
2551 continue;
2550 for_each_subsys(ss, ssid) { 2552 for_each_subsys(ss, ssid) {
2551 if (ss->disabled || strcmp(tok + 1, ss->name)) 2553 if (ss->disabled || strcmp(tok + 1, ss->name))
2552 continue; 2554 continue;