diff options
author | Alban Crequy <alban.crequy@collabora.co.uk> | 2014-08-18 12:20:20 +0100 |
---|---|---|
committer | Zefan Li <lizefan@huawei.com> | 2014-12-01 18:02:23 +0800 |
commit | a48fec2f276f8003fb8098df892ea3acb5d7149a (patch) | |
tree | f9215afbe8d73833a7c5eaba2f6dc54ed4b8f96c /kernel | |
parent | c16060dfda1c8418a9e638b79f5d2101b482e89f (diff) |
cgroup: reject cgroup names with ' '
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@collabora.co.uk>
Signed-off-by: Tejun Heo <tj@kernel.org>
[lizf: Backported to 3.4:
- adjust context
- s/name/dentry->d_name.name/]
Signed-off-by: Zefan Li <lizefan@huawei.com>
Diffstat (limited to 'kernel')
-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 7c8f4f7d0c71..c776f8941175 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -3838,6 +3838,11 @@ static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct cgroup *c_parent = dentry->d_parent->d_fsdata; + /* Do not accept '\n' to prevent making /proc/<pid>/cgroup unparsable. + */ + if (strchr(dentry->d_name.name, '\n')) + return -EINVAL; + /* the vfs holds inode->i_mutex already */ return cgroup_create(c_parent, dentry, mode | S_IFDIR); } |