Skip to content

Commit

Permalink
cgroup: reject cgroup names with '\n'
Browse files Browse the repository at this point in the history
/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
  • Loading branch information
Alban Crequy authored and Tejun Heo committed Aug 18, 2014
1 parent 7d1311b commit 71b1fb5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 71b1fb5

Please sign in to comment.