diff mbox series

[v1] cgroup_core01.c: Set umask before create directory

Message ID 20231204002623.17302-1-wegao@suse.com
State Superseded
Headers show
Series [v1] cgroup_core01.c: Set umask before create directory | expand

Commit Message

Wei Gao Dec. 4, 2023, 12:26 a.m. UTC
Some specific build's default mask is 0077, this will trigger issue if
you create directory with A but switch B to access it. Such as following
failed message will popup in current case:
cgroup_core01.c:50: TBROK: openat(21</sys/fs/cgroup/memory/ltp/test-3519/child_b>, 'tasks', 2, 0): EACCES (13)

Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/controllers/cgroup/cgroup_core01.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Andrea Cervesato Feb. 12, 2024, 11:54 a.m. UTC | #1
Hi!
LGTM

Reviewed-by: Andrea Cervesato <andrea.cervesato.suse.com>

On 12/4/23 01:26, Wei Gao via ltp wrote:
> Some specific build's default mask is 0077, this will trigger issue if
> you create directory with A but switch B to access it. Such as following
> failed message will popup in current case:
> cgroup_core01.c:50: TBROK: openat(21</sys/fs/cgroup/memory/ltp/test-3519/child_b>, 'tasks', 2, 0): EACCES (13)
>
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
>   testcases/kernel/controllers/cgroup/cgroup_core01.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/testcases/kernel/controllers/cgroup/cgroup_core01.c b/testcases/kernel/controllers/cgroup/cgroup_core01.c
> index 2e695deed..0deff6209 100644
> --- a/testcases/kernel/controllers/cgroup/cgroup_core01.c
> +++ b/testcases/kernel/controllers/cgroup/cgroup_core01.c
> @@ -38,6 +38,7 @@ static void test_lesser_euid_open(void)
>   	int fds[TST_CG_ROOTS_MAX] = {-1};
>   	int i, loops;
>   
> +	umask(0022);
>   	cg_child_a = tst_cg_group_mk(tst_cg, "child_a");
>   	cg_child_b = tst_cg_group_mk(tst_cg, "child_b");
>
diff mbox series

Patch

diff --git a/testcases/kernel/controllers/cgroup/cgroup_core01.c b/testcases/kernel/controllers/cgroup/cgroup_core01.c
index 2e695deed..0deff6209 100644
--- a/testcases/kernel/controllers/cgroup/cgroup_core01.c
+++ b/testcases/kernel/controllers/cgroup/cgroup_core01.c
@@ -38,6 +38,7 @@  static void test_lesser_euid_open(void)
 	int fds[TST_CG_ROOTS_MAX] = {-1};
 	int i, loops;
 
+	umask(0022);
 	cg_child_a = tst_cg_group_mk(tst_cg, "child_a");
 	cg_child_b = tst_cg_group_mk(tst_cg, "child_b");