]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgfs: skip empty entries under /proc/self/cgroup
authorChristian Brauner <christian.brauner@canonical.com>
Sun, 30 Oct 2016 12:42:37 +0000 (13:42 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 18 Nov 2016 01:33:41 +0000 (20:33 -0500)
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 <christian.brauner@canonical.com>
src/lxc/cgfs.c

index 4474c84726756a8438136316bc41a4bc41603aa8..250b811611443b628da63246d74f2421adf52d06 100644 (file)
@@ -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;