Commit 5204214f authored by Zefan Li's avatar Zefan Li Committed by yanhaitao
Browse files

cgroup: check if cgroup root is alive in cgroupstats_show()

euler inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8QLND


CVE: N/A

-------------------------------------------------

If a cgroup root is dying, show its hierarchy_id and num_cgroups
as 0.

Signed-off-by: default avatarZefan Li <lizefan@huawei.com>
Signed-off-by: default avatarchenridong <chenridong@huawei.com>
parent 6d225089
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -675,6 +675,7 @@ int proc_cgroupstats_show(struct seq_file *m, void *v)
{
	struct cgroup_subsys *ss;
	int i;
	bool dead;

	seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n");
	/*
@@ -682,11 +683,13 @@ int proc_cgroupstats_show(struct seq_file *m, void *v)
	 * cgroup_mutex contention.
	 */

	for_each_subsys(ss, i)
	for_each_subsys(ss, i) {
		dead = percpu_ref_is_dying(&ss->root->cgrp.self.refcnt);
		seq_printf(m, "%s\t%d\t%d\t%d\n",
			   ss->legacy_name, ss->root->hierarchy_id,
			   atomic_read(&ss->root->nr_cgrps),
			   ss->legacy_name, dead ? 0 : ss->root->hierarchy_id,
			   dead ? 0 : atomic_read(&ss->root->nr_cgrps),
			   cgroup_ssid_enabled(i));
	}

	return 0;
}