Commit 767f5ccd authored by Alban Crequy's avatar Alban Crequy Committed by Greg Kroah-Hartman

cgroup: reject cgroup names with '\n'

commit 71b1fb5c 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: default avatarAlban Crequy <alban.crequy@collabora.co.uk>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6ea8d7ba
...@@ -4393,6 +4393,11 @@ static int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name, ...@@ -4393,6 +4393,11 @@ static int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name,
struct kernfs_node *kn; struct kernfs_node *kn;
int ssid, ret; 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); parent = cgroup_kn_lock_live(parent_kn);
if (!parent) if (!parent)
return -ENODEV; return -ENODEV;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment