Re: [PATCH] selftests: cgroup: simplify cpuset subtree permissions test
From: Waiman Long
Date: Wed Aug 19 2026 - 10:34:52 EST
On 8/19/26 6:31 AM, Shaojie Sun wrote:
Simplify test_cpuset_perms_subtree by removing unnecessary chown ofReviewed-by: Waiman Long <longman@xxxxxxxxxx>
cgroup.procs files. The test verifies implicit migration triggered by
enabling/disabling the cpuset controller via cgroup.subtree_control.
Implicit migration is handled internally by the kernel through
cgroup_update_dfl_csses() when subtree_control is modified, and does
not require cgroup.procs write permission. Only cgroup.subtree_control
permission is needed to trigger the controller state change.
Remove the allocation and cleanup of parent_procs and child_procs
variables that are no longer needed.
Signed-off-by: Shaojie Sun <sunshaojie@xxxxxxxxxx>
---
tools/testing/selftests/cgroup/test_cpuset.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/cgroup/test_cpuset.c b/tools/testing/selftests/cgroup/test_cpuset.c
index c5cf8b56ceb8..b323addcc519 100644
--- a/tools/testing/selftests/cgroup/test_cpuset.c
+++ b/tools/testing/selftests/cgroup/test_cpuset.c
@@ -167,7 +167,7 @@ static int test_cpuset_perms_object_deny(const char *root)
static int test_cpuset_perms_subtree(const char *root)
{
char *parent = NULL, *child = NULL;
- char *parent_procs = NULL, *parent_subctl = NULL, *child_procs = NULL;
+ char *parent_subctl = NULL;
const uid_t test_euid = TEST_UID;
int object_pid = 0;
int ret = KSFT_FAIL;
@@ -175,9 +175,6 @@ static int test_cpuset_perms_subtree(const char *root)
parent = cg_name(root, "cpuset_test_0");
if (!parent)
goto cleanup;
- parent_procs = cg_name(parent, "cgroup.procs");
- if (!parent_procs)
- goto cleanup;
parent_subctl = cg_name(parent, "cgroup.subtree_control");
if (!parent_subctl)
goto cleanup;
@@ -187,16 +184,11 @@ static int test_cpuset_perms_subtree(const char *root)
child = cg_name(parent, "cpuset_test_1");
if (!child)
goto cleanup;
- child_procs = cg_name(child, "cgroup.procs");
- if (!child_procs)
- goto cleanup;
if (cg_create(child))
goto cleanup;
- /* Enable permissions as in a delegated subtree */
- if (chown(parent_procs, test_euid, -1) ||
- chown(parent_subctl, test_euid, -1) ||
- chown(child_procs, test_euid, -1))
+ /* Grant minimal subtree_control permission to trigger implicit migration */
+ if (chown(parent_subctl, test_euid, -1))
goto cleanup;
/* Put a privileged child in the subtree and modify controller state
@@ -221,12 +213,10 @@ static int test_cpuset_perms_subtree(const char *root)
}
cg_destroy(child);
- free(child_procs);
free(child);
cg_destroy(parent);
free(parent_subctl);
- free(parent_procs);
free(parent);
return ret;