* [PATCH v2] cgroup: reject cgroup names with '\n'
@ 2014-08-18 11:20 Alban Crequy
[not found] ` <1408360820-3390-1-git-send-email-alban.crequy-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Alban Crequy @ 2014-08-18 11:20 UTC (permalink / raw)
To: Alban Crequy, Tejun Heo, cgroups, linux-kernel, Li Zefan
/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>
---
v2: Fixed according to comments from Tejun Heo: only reject '\n'
kernel/cgroup.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 7dc8788..c3d1802 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -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;
--
1.8.5.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] cgroup: reject cgroup names with '\n'
[not found] ` <1408360820-3390-1-git-send-email-alban.crequy-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
@ 2014-08-18 14:20 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2014-08-18 14:20 UTC (permalink / raw)
To: Alban Crequy
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Li Zefan
On Mon, Aug 18, 2014 at 12:20:20PM +0100, Alban Crequy wrote:
> /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-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
Applied to cgroup/for-3.17-fixes w/ stable cc'd.
Thanks!
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-18 14:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-18 11:20 [PATCH v2] cgroup: reject cgroup names with '\n' Alban Crequy
[not found] ` <1408360820-3390-1-git-send-email-alban.crequy-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2014-08-18 14:20 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).