public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] cgroup_dir_mk: set the umask to '0' before creating the subdir
@ 2024-03-01 10:23 Li Wang
  2024-03-01 11:51 ` Petr Vorel
  2024-03-03  9:46 ` Wei Gao via ltp
  0 siblings, 2 replies; 5+ messages in thread
From: Li Wang @ 2024-03-01 10:23 UTC (permalink / raw)
  To: ltp

This is to resolve the permission issue when creating
a new subdir in the cgroup, in case of 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)

Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Wei Gao <wegao@suse.com>
---

Notes:
    Hi Wei, can you help confirm if this patch works for you?

 lib/tst_cgroup.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
index a8a598e0e..f6afb51d6 100644
--- a/lib/tst_cgroup.c
+++ b/lib/tst_cgroup.c
@@ -361,6 +361,7 @@ static void cgroup_dir_mk(const struct cgroup_dir *const parent,
 			  struct cgroup_dir *const new)
 {
 	const char *dpath;
+	mode_t old_umask = umask(0);
 
 	new->dir_root = parent->dir_root;
 	new->dir_name = dir_name;
@@ -394,6 +395,7 @@ static void cgroup_dir_mk(const struct cgroup_dir *const parent,
 opendir:
 	new->dir_fd = SAFE_OPENAT(parent->dir_fd, dir_name,
 				  O_PATH | O_DIRECTORY);
+	umask(old_umask);
 }
 
 #define PATH_MAX_STRLEN 4095
-- 
2.40.1


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] cgroup_dir_mk: set the umask to '0' before creating the subdir
  2024-03-01 10:23 [LTP] [PATCH] cgroup_dir_mk: set the umask to '0' before creating the subdir Li Wang
@ 2024-03-01 11:51 ` Petr Vorel
  2024-03-03 10:33   ` Wei Gao via ltp
  2024-03-03  9:46 ` Wei Gao via ltp
  1 sibling, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2024-03-01 11:51 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp

Hi Li, Wei,

> This is to resolve the permission issue when creating
> a new subdir in the cgroup, in case of 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)

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Setting this on single place which *should* fix problems, but still not affect
whole LTP API looks good to me. BTW there were more tests which needed it,
e.g. testcases/kernel/syscalls/statx/statx07.c
https://patchwork.ozlabs.org/project/ltp/patch/20240222031018.12281-3-wegao@suse.com/

Therefore this solves just some problems.

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] cgroup_dir_mk: set the umask to '0' before creating the subdir
  2024-03-01 10:23 [LTP] [PATCH] cgroup_dir_mk: set the umask to '0' before creating the subdir Li Wang
  2024-03-01 11:51 ` Petr Vorel
@ 2024-03-03  9:46 ` Wei Gao via ltp
  2024-03-03 12:42   ` Petr Vorel
  1 sibling, 1 reply; 5+ messages in thread
From: Wei Gao via ltp @ 2024-03-03  9:46 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp

On Fri, Mar 01, 2024 at 06:23:47PM +0800, Li Wang wrote:
> This is to resolve the permission issue when creating
> a new subdir in the cgroup, in case of 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)
> 
> Signed-off-by: Li Wang <liwang@redhat.com>
> Cc: Wei Gao <wegao@suse.com>
> ---
> 
> Notes:
>     Hi Wei, can you help confirm if this patch works for you?

@Li I have tested your patch and it can work.
@Li @Petr Thanks for your patch and comments, i suppose this patch can be merged.

> 
>  lib/tst_cgroup.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
> index a8a598e0e..f6afb51d6 100644
> --- a/lib/tst_cgroup.c
> +++ b/lib/tst_cgroup.c
> @@ -361,6 +361,7 @@ static void cgroup_dir_mk(const struct cgroup_dir *const parent,
>  			  struct cgroup_dir *const new)
>  {
>  	const char *dpath;
> +	mode_t old_umask = umask(0);
>  
>  	new->dir_root = parent->dir_root;
>  	new->dir_name = dir_name;
> @@ -394,6 +395,7 @@ static void cgroup_dir_mk(const struct cgroup_dir *const parent,
>  opendir:
>  	new->dir_fd = SAFE_OPENAT(parent->dir_fd, dir_name,
>  				  O_PATH | O_DIRECTORY);
> +	umask(old_umask);
>  }
>  
>  #define PATH_MAX_STRLEN 4095
> -- 
> 2.40.1
> 

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] cgroup_dir_mk: set the umask to '0' before creating the subdir
  2024-03-01 11:51 ` Petr Vorel
@ 2024-03-03 10:33   ` Wei Gao via ltp
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Gao via ltp @ 2024-03-03 10:33 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

On Fri, Mar 01, 2024 at 12:51:31PM +0100, Petr Vorel wrote:
> Hi Li, Wei,
> 
> > This is to resolve the permission issue when creating
> > a new subdir in the cgroup, in case of 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)
> 
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> 
> Setting this on single place which *should* fix problems, but still not affect
> whole LTP API looks good to me. BTW there were more tests which needed it,
> e.g. testcases/kernel/syscalls/statx/statx07.c
> https://patchwork.ozlabs.org/project/ltp/patch/20240222031018.12281-3-wegao@suse.com/
> 
Send new patch for stat07:
https://patchwork.ozlabs.org/project/ltp/patch/20240303103105.13401-1-wegao@suse.com/

> Therefore this solves just some problems.
> 
> Kind regards,
> Petr
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] cgroup_dir_mk: set the umask to '0' before creating the subdir
  2024-03-03  9:46 ` Wei Gao via ltp
@ 2024-03-03 12:42   ` Petr Vorel
  0 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2024-03-03 12:42 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi Li, Wei,

...
> > Notes:
> >     Hi Wei, can you help confirm if this patch works for you?

> @Li I have tested your patch and it can work.
> @Li @Petr Thanks for your patch and comments, i suppose this patch can be merged.

I added Wei's RBT and TBT and merged.
Thank to you both!

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-03 12:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-01 10:23 [LTP] [PATCH] cgroup_dir_mk: set the umask to '0' before creating the subdir Li Wang
2024-03-01 11:51 ` Petr Vorel
2024-03-03 10:33   ` Wei Gao via ltp
2024-03-03  9:46 ` Wei Gao via ltp
2024-03-03 12:42   ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox