[3.13.y.z extended stable] Patch "cgroup: reject cgroup names with '\n'" has been added to staging queue

Kamal Mostafa kamal at canonical.com
Wed Oct 8 22:13:57 UTC 2014

This is a note to let you know that I have just added a patch titled

    cgroup: reject cgroup names with '\n'

to the linux-3.13.y-queue branch of the 3.13.y.z extended stable tree 
which can be found at:


This patch is scheduled to be released in version

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.13.y.z tree, see



>From ac229fd9b9bce12c5889255eff61135faf0d59ac Mon Sep 17 00:00:00 2001
From: Alban Crequy <alban.crequy at collabora.co.uk>
Date: Mon, 18 Aug 2014 12:20:20 +0100
Subject: cgroup: reject cgroup names with '\n'

commit 71b1fb5c4473a5b1e601d41b109bdfe001ec82e0 upstream.

/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 at collabora.co.uk>
Signed-off-by: Tejun Heo <tj at kernel.org>
[ kamal: backport to 3.13-stable: fixed in cgroup_create() ]
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
 kernel/cgroup.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index b44dd49..8e5e0a9 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4350,6 +4350,11 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
 	struct cgroup_subsys *ss;
 	struct super_block *sb = root->sb;

+	/* Do not accept '\n' to prevent making /proc/<pid>/cgroup unparsable.
+	 */
+	if (strchr(dentry->d_name.name, '\n'))
+		return -EINVAL;
 	/* allocate the cgroup and its ID, 0 is reserved for the root */
 	cgrp = kzalloc(sizeof(*cgrp), GFP_KERNEL);
 	if (!cgrp)

More information about the kernel-team mailing list