[CRIU] [PATCH] cgroups: Make sure the cgroup formatted correctly

Cyrill Gorcunov gorcunov at openvz.org
Mon Jul 14 06:40:49 PDT 2014


In case if something is broken in the kernel and
we get a format corrupted -- simply exit out with
error instead of strlen'ing nil string.

Also while at it -- add a comment about format.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 proc_parse.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/proc_parse.c b/proc_parse.c
index 88f3c0a9c5bb..1c66782586c3 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -1530,8 +1530,20 @@ int parse_task_cgroup(int pid, struct list_head *retl, unsigned int *n)
 		if (!ncc)
 			goto err;
 
+		/*
+		 * Typical output (':' is a separator here)
+		 *
+		 * 4:cpu,cpuacct:/
+		 * 3:cpuset:/
+		 * 2:name=systemd:/user.slice/user-1000.slice/session-1.scope
+		 */
 		name = strchr(buf, ':') + 1;
 		path = strchr(name, ':');
+		if (!name || !path) {
+			pr_err("Failed parsing cgroup %s\n", buf);
+			xfree(ncc);
+			goto err;
+		}
 		e = strchr(name, '\n');
 		*path++ = '\0';
 		if (e)
-- 
1.9.3



More information about the CRIU mailing list