Skip to content

Commit

Permalink
cgfs: skip empty entries under /proc/self/cgroup
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christian Brauner committed Oct 30, 2016
1 parent 1a70401 commit 82a2fe0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lxc/cgroups/cgfs.c
Expand Up @@ -364,6 +364,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;
Expand Down Expand Up @@ -1685,6 +1693,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;
Expand Down

0 comments on commit 82a2fe0

Please sign in to comment.