[LTP] [PATCH v4 1/2] cgroup_core01.c: Set system default umaks to 0
Wei Gao
wegao@suse.com
Wed Feb 21 09:42:55 CET 2024
When system's default umask is 0077, this will trigger issues for LTP case.
cgroup_core01.c will report following error msg:
cgroup_core01.c:50: TBROK: openat(21</sys/fs/cgroup/memory/ltp/test-3519/child_b>, 'tasks', 2, 0): EACCES (13)
Detail reason:
Code:
cg_child_a = tst_cg_group_mk(tst_cg, "child_a");
cg_child_b = tst_cg_group_mk(tst_cg, "child_b");
Result:
wegao:/sys/fs/cgroup # ll ltp/test-25304/
drwx------ 2 root root 0 Feb 10 10:37 child_a <<<<<< group and other has no any permission
drwx------ 2 root root 0 Feb 10 10:38 child_b
Code:
SAFE_CG_FCHOWN(cg_child_a, "cgroup.procs", nobody_uid, -1);
SAFE_CG_FCHOWN(cg_child_b, "cgroup.procs", nobody_uid, -1);
Result:
wegao:/sys/fs/cgroup # ll ltp/test-26388/child_a/
total 0
-rw-r--r-- 1 nobody root 0 Feb 10 10:44 cgroup.procs <<<<<<
Code:
SAFE_SETEUID(nobody_uid); <<<< after switch to nobody then can not access child_{a,b} or any file
under child_{a,b}
Result:
nobody@wegao:/sys/fs/cgroup/ltp/test-26730> ll child_a/ <<< nobody has no permission on child_a
ls: cannot open directory 'child_a/': Permission denied
Code:
loops = SAFE_CG_OPEN(cg_child_b, "cgroup.procs", O_RDWR, fds);
Result:
cgroup_core01.c:76: TBROK: openat(9</sys/fs/cgroup/ltp/test-26388/child_b>, 'cgroup.procs', 2, 0): EACCES (13)
Signed-off-by: Wei Gao <wegao@suse.com>
---
testcases/kernel/controllers/cgroup/cgroup_core01.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/testcases/kernel/controllers/cgroup/cgroup_core01.c b/testcases/kernel/controllers/cgroup/cgroup_core01.c
index 2e695deed..ad08c74a9 100644
--- a/testcases/kernel/controllers/cgroup/cgroup_core01.c
+++ b/testcases/kernel/controllers/cgroup/cgroup_core01.c
@@ -76,6 +76,8 @@ static void setup(void)
{
struct passwd *pw;
+ umask(0);
+
pw = SAFE_GETPWNAM("nobody");
nobody_uid = pw->pw_uid;
save_uid = geteuid();
--
2.35.3
More information about the ltp
mailing list