Re: [PATCH v2 07/11] selftests/cgroup: test the frozen state of a cgroup with tasks and children
From: Andrew Morton
Date: Tue Dec 01 2026 - 12:55:52 EST
On Mon, 30 Nov 2026 09:34:21 -0800 Shakeel Butt <shakeel.butt@xxxxxxxxx> wrote:
> Add a test for a cgroup that has tasks of its own and a child cgroup. It
> must report frozen only when its own tasks and the child are all frozen,
> and it must not stay frozen after a thaw.
>
> To get a task that the cgroup2 freezer can't stop, freeze it in a cgroup
> v1 freezer hierarchy. It then sleeps in the refrigerator, where the
> cgroup2 freezer can't trap it. A stopped task counts as frozen, and a
> thaw doesn't wake it. The test is skipped if the v1 freezer can't be
> mounted.
>
> Without "cgroup/freezer: check own tasks and descendants for the frozen
> state", the parent reports frozen=1 while its child is not frozen.
From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Subject: selftests/cgroup: check the nonleaf parent path allocation
Date: Tue, 01 Dec 2026 01:38:45 -0800
The new nonleaf freezer test builds its child path from parent before
checking whether cg_name() allocated parent. If that allocation fails,
cg_name() calls strlen(NULL) and the entire test process segfaults before
it can unmount the v1 freezer hierarchy or report a failed test.
This fixes Shakeel Butt's "selftests/cgroup: test the frozen state of a
cgroup with tasks and children" patch.
Check parent immediately after allocating it. The cleanup path already
accepts a NULL cgroup path, so the test reports failure and unmounts the
v1 hierarchy.
A source edit that forced the first cg_name() result to NULL made the v2
selftest segfault after TAP case 10. The fixed, injected selftest
reports case 11 as failed and runs the remaining cases.
Link: https://lore.kernel.org/r/20261130173425.4117363-8-shakeel.butt@xxxxxxxxx
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Tejun Heo <tj@xxxxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: Michal Koutný <mkoutny@xxxxxxxx>
Cc: Shuah Khan <shuah@xxxxxxxxxx>
tools/testing/selftests/cgroup/test_freezer.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/tools/testing/selftests/cgroup/test_freezer.c~selftests-cgroup-test-the-frozen-state-of-a-cgroup-with-tasks-and-children-fix
+++ a/tools/testing/selftests/cgroup/test_freezer.c
@@ -832,10 +832,12 @@ static int test_cgfreezer_nonleaf(const
mounted = true;
parent = cg_name(root, "cg_test_nonleaf");
+ if (!parent)
+ goto cleanup;
child = cg_name(parent, "child");
staging = cg_name(root, "cg_test_nonleaf_staging");
v1cg = cg_name(v1root, "cg_test_nonleaf");
- if (!parent || !child || !staging || !v1cg)
+ if (!child || !staging || !v1cg)
goto cleanup;
if (cg_create(parent) || cg_create(child) || cg_create(staging) ||
_