diff options
author | Alban Crequy <alban.crequy@collabora.co.uk> | 2014-08-18 07:20:20 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-08-18 10:18:57 -0400 |
commit | 71b1fb5c4473a5b1e601d41b109bdfe001ec82e0 (patch) | |
tree | 6116b623ff191046a53f6a93906f17d7e9d4afec | |
parent | 7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff) |
cgroup: reject cgroup names with '\n'
/proc/<pid>/cgroup contains one cgroup path on each line. If cgroup names are
allowed to contain "\n", applications cannot parse /proc/<pid>/cgroup safely.
Signed-off-by: Alban Crequy <alban.crequy@collabora.co.uk>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: stable@vger.kernel.org
-rw-r--r-- | kernel/cgroup.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 7dc8788cfd52..c3d1802a9b30 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -4543,6 +4543,11 @@ static int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name, | |||
4543 | struct cftype *base_files; | 4543 | struct cftype *base_files; |
4544 | int ssid, ret; | 4544 | int ssid, ret; |
4545 | 4545 | ||
4546 | /* Do not accept '\n' to prevent making /proc/<pid>/cgroup unparsable. | ||
4547 | */ | ||
4548 | if (strchr(name, '\n')) | ||
4549 | return -EINVAL; | ||
4550 | |||
4546 | parent = cgroup_kn_lock_live(parent_kn); | 4551 | parent = cgroup_kn_lock_live(parent_kn); |
4547 | if (!parent) | 4552 | if (!parent) |
4548 | return -ENODEV; | 4553 | return -ENODEV; |