summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaojie Sun <sunshaojie@kylinos.cn>2026-08-14 18:00:02 +0800
committerTejun Heo <tj@kernel.org>2026-08-14 08:32:58 -1000
commit2d19207f3fc8e08bab3270af2e3835358ab1473a (patch)
treee4aa52f9415b4e00df922f1675f911c488c25287
parentddabc5dbd262f3ca981e679ddae99ed7a9adb279 (diff)
downloadlinux-next-2d19207f3fc8e08bab3270af2e3835358ab1473a.tar.gz
linux-next-2d19207f3fc8e08bab3270af2e3835358ab1473a.zip
selftests/cgroup: Remove redundant chown in test_cgcore_lesser_ns_open
test_cgcore_lesser_ns_open runs as root throughout and never changes its euid, so chowning the two cgroup.procs files to a non-root uid has no effect on the test. The ENOENT the test expects comes from the cgroup namespace delegation check in cgroup_procs_write_permission(): the source and destination cgroups must both be descendants of the namespace root captured at open time. That check does not depend on file ownership. In addition, the permission check only examines the common ancestor's cgroup.procs file (the test root here), which the chown calls do not touch. Remove the redundant chown calls and the now unused test_euid and cg_test_a_procs variables. Signed-off-by: Shaojie Sun <sunshaojie@kylinos.cn> Reviewed-by: Tao Cui <cuitao@kylinos.cn> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--tools/testing/selftests/cgroup/test_core.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/tools/testing/selftests/cgroup/test_core.c b/tools/testing/selftests/cgroup/test_core.c
index 8e3f9b391e44..e9bee164bb70 100644
--- a/tools/testing/selftests/cgroup/test_core.c
+++ b/tools/testing/selftests/cgroup/test_core.c
@@ -794,10 +794,9 @@ static int lesser_ns_open_thread_fn(void *arg)
static int test_cgcore_lesser_ns_open(const char *root)
{
static char stack[65536];
- const uid_t test_euid = 65534; /* usually nobody, any !root is fine */
int ret = KSFT_FAIL;
char *cg_test_a = NULL, *cg_test_b = NULL;
- char *cg_test_a_procs = NULL, *cg_test_b_procs = NULL;
+ char *cg_test_b_procs = NULL;
int cg_test_b_procs_fd = -1;
struct lesser_ns_open_thread_arg targ = { .fd = -1 };
pid_t pid;
@@ -812,10 +811,9 @@ static int test_cgcore_lesser_ns_open(const char *root)
if (!cg_test_a || !cg_test_b)
goto cleanup;
- cg_test_a_procs = cg_name(cg_test_a, "cgroup.procs");
cg_test_b_procs = cg_name(cg_test_b, "cgroup.procs");
- if (!cg_test_a_procs || !cg_test_b_procs)
+ if (!cg_test_b_procs)
goto cleanup;
if (cg_create(cg_test_a) || cg_create(cg_test_b))
@@ -824,10 +822,6 @@ static int test_cgcore_lesser_ns_open(const char *root)
if (cg_enter_current(cg_test_b))
goto cleanup;
- if (chown(cg_test_a_procs, test_euid, -1) ||
- chown(cg_test_b_procs, test_euid, -1))
- goto cleanup;
-
targ.path = cg_test_b_procs;
pid = clone(lesser_ns_open_thread_fn, stack + sizeof(stack),
CLONE_NEWCGROUP | CLONE_FILES | CLONE_VM | SIGCHLD,
@@ -862,7 +856,6 @@ cleanup:
if (cg_test_a)
cg_destroy(cg_test_a);
free(cg_test_b_procs);
- free(cg_test_a_procs);
free(cg_test_b);
free(cg_test_a);
return ret;