cgroup: reject cgroup names with '\n'
authorAlban Crequy <alban.crequy@collabora.co.uk>
Mon, 18 Aug 2014 11:20:20 +0000 (12:20 +0100)
committerTejun Heo <tj@kernel.org>
Mon, 18 Aug 2014 14:18:57 +0000 (10:18 -0400)
/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
kernel/cgroup.c

index 7dc8788cfd52dd222856057840a8d0a45a19816e..c3d1802a9b30c0f7a58a30d564315fefb7327fc8 100644 (file)
@@ -4543,6 +4543,11 @@ static int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name,
        struct cftype *base_files;
        int ssid, ret;
 
+       /* Do not accept '\n' to prevent making /proc/<pid>/cgroup unparsable.
+        */
+       if (strchr(name, '\n'))
+               return -EINVAL;
+
        parent = cgroup_kn_lock_live(parent_kn);
        if (!parent)
                return -ENODEV;