From 2ca5963c28a4f7b9149586c7490d5bc534506e95 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sun, 30 Oct 2016 13:42:37 +0100 Subject: [PATCH] cgfs: skip empty entries under /proc/self/cgroup If cgroupv2 is enabled either alone or together with legacy hierarchies /proc/self/cgroup can contain entries of the form: 0::/ These entries need to be skipped. Signed-off-by: Christian Brauner --- src/lxc/cgfs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lxc/cgfs.c b/src/lxc/cgfs.c index 4474c8472..250b81161 100644 --- a/src/lxc/cgfs.c +++ b/src/lxc/cgfs.c @@ -348,6 +348,14 @@ static bool find_cgroup_hierarchies(struct cgroup_meta_data *meta_data, *colon2 = '\0'; colon2 = NULL; + + /* With cgroupv2 /proc/self/cgroup can contain entries of the + * form: 0::/ + * These entries need to be skipped. + */ + if (!strcmp(colon1, "")) + continue; + hierarchy_number = strtoul(line, &colon2, 10); if (!colon2 || *colon2) continue; @@ -1648,6 +1656,14 @@ lxc_cgroup_process_info_getx(const char *proc_pid_cgroup_str, *colon2++ = '\0'; endptr = NULL; + + /* With cgroupv2 /proc/self/cgroup can contain entries of the + * form: 0::/ + * These entries need to be skipped. + */ + if (!strcmp(colon1, "")) + continue; + hierarchy_number = strtoul(line, &endptr, 10); if (!endptr || *endptr) continue; -- 2.47.2