public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Wei Gao via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 1/2] cgroup_core01.c: Set system default umaks to 0022
Date: Wed, 21 Feb 2024 02:16:34 -0500	[thread overview]
Message-ID: <20240221071635.17239-2-wegao@suse.com> (raw)
In-Reply-To: <20240221071635.17239-1-wegao@suse.com>

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..80d13a9c5 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(0022);
+
 	pw = SAFE_GETPWNAM("nobody");
 	nobody_uid = pw->pw_uid;
 	save_uid = geteuid();
-- 
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-02-21  7:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04  0:26 [LTP] [PATCH v1] cgroup_core01.c: Set umask before create directory Wei Gao via ltp
2024-02-12 11:54 ` Andrea Cervesato via ltp
2024-02-19 13:48 ` [LTP] [PATCH v2] tst_test.c: Set system default umaks to 0022 Wei Gao via ltp
2024-02-20  9:18   ` Petr Vorel
2024-02-21  8:33     ` Wei Gao via ltp
2024-02-21 16:19       ` Petr Vorel
2024-02-22 13:53         ` Wei Gao via ltp
2024-02-21  7:16   ` [LTP] [PATCH v3 0/2] " Wei Gao via ltp
2024-02-21  7:16     ` Wei Gao via ltp [this message]
2024-02-21  7:16     ` [LTP] [PATCH v3 2/2] statx07.c: set umask " Wei Gao via ltp
2024-02-21  7:32       ` Petr Vorel
2024-02-21  8:42     ` [LTP] [PATCH v3 0/2] Set system default umaks to 0 Wei Gao via ltp
2024-02-21  8:42       ` [LTP] [PATCH v4 1/2] cgroup_core01.c: " Wei Gao via ltp
2024-02-21  8:42       ` [LTP] [PATCH v4 2/2] statx07.c: set umask " Wei Gao via ltp
2024-02-22  3:10       ` [LTP] [PATCH v5 0/2] Set system default umaks " Wei Gao via ltp
2024-02-22  3:10         ` [LTP] [PATCH v5 1/2] cgroup_core01.c: " Wei Gao via ltp
2024-03-01  7:26           ` Li Wang
2024-03-01  8:43             ` Petr Vorel
2024-03-01 10:07               ` Li Wang
2024-02-22  3:10         ` [LTP] [PATCH v5 2/2] statx07.c: set umask " Wei Gao via ltp
2024-03-01  7:28           ` Li Wang
2024-03-01 11:52             ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240221071635.17239-2-wegao@suse.com \
    --to=ltp@lists.linux.it \
    --cc=wegao@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox