public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nsproxy: remove judge of timens_on_fork()'s return val
@ 2020-11-15 18:14 Hui Su
  2020-11-17  8:30 ` Andrey Vagin
  0 siblings, 1 reply; 3+ messages in thread
From: Hui Su @ 2020-11-15 18:14 UTC (permalink / raw)
  To: christian.brauner, serge, avagin, tglx, linux-kernel; +Cc: sh_def

timens_on_fork() always return 0, and maybe not
need to judge the return value in copy_namespaces().

Signed-off-by: Hui Su <sh_def@163.com>
---
 kernel/nsproxy.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index 12dd41b39a7f..e2e6c5dc433f 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -153,7 +153,6 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)
 	struct nsproxy *old_ns = tsk->nsproxy;
 	struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);
 	struct nsproxy *new_ns;
-	int ret;
 
 	if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
 			      CLONE_NEWPID | CLONE_NEWNET |
@@ -180,11 +179,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)
 	if (IS_ERR(new_ns))
 		return  PTR_ERR(new_ns);
 
-	ret = timens_on_fork(new_ns, tsk);
-	if (ret) {
-		free_nsproxy(new_ns);
-		return ret;
-	}
+	timens_on_fork(new_ns, tsk);
 
 	tsk->nsproxy = new_ns;
 	return 0;
-- 
2.29.0



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

* Re: [PATCH] nsproxy: remove judge of timens_on_fork()'s return val
  2020-11-15 18:14 [PATCH] nsproxy: remove judge of timens_on_fork()'s return val Hui Su
@ 2020-11-17  8:30 ` Andrey Vagin
  2020-11-17 15:35   ` Hui Su
  0 siblings, 1 reply; 3+ messages in thread
From: Andrey Vagin @ 2020-11-17  8:30 UTC (permalink / raw)
  To: Hui Su; +Cc: Christian Brauner, Serge E. Hallyn, Thomas Gleixner, LKML

On Sun, Nov 15, 2020 at 10:36 AM Hui Su <sh_def@163.com> wrote:
>
> timens_on_fork() always return 0, and maybe not
> need to judge the return value in copy_namespaces().

Thank you for cleaning this up. I think we can go even further and
change timens_on_fork to return nothing:

-int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk)
+void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk)
 {
        struct ns_common *nsc = &nsproxy->time_ns_for_children->ns;
        struct time_namespace *ns = to_time_ns(nsc);

        /* create_new_namespaces() already incremented the ref counter */
        if (nsproxy->time_ns == nsproxy->time_ns_for_children)
-               return 0;
+               return;

        get_time_ns(ns);
        put_time_ns(nsproxy->time_ns);
        nsproxy->time_ns = ns;

        timens_commit(tsk, ns);
-
-       return 0;
 }


>
> Signed-off-by: Hui Su <sh_def@163.com>
> ---
>  kernel/nsproxy.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
> index 12dd41b39a7f..e2e6c5dc433f 100644
> --- a/kernel/nsproxy.c
> +++ b/kernel/nsproxy.c
> @@ -153,7 +153,6 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)
>         struct nsproxy *old_ns = tsk->nsproxy;
>         struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);
>         struct nsproxy *new_ns;
> -       int ret;
>
>         if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
>                               CLONE_NEWPID | CLONE_NEWNET |
> @@ -180,11 +179,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)
>         if (IS_ERR(new_ns))
>                 return  PTR_ERR(new_ns);
>
> -       ret = timens_on_fork(new_ns, tsk);
> -       if (ret) {
> -               free_nsproxy(new_ns);
> -               return ret;
> -       }
> +       timens_on_fork(new_ns, tsk);
>
>         tsk->nsproxy = new_ns;
>         return 0;
> --
> 2.29.0
>
>

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

* Re: [PATCH] nsproxy: remove judge of timens_on_fork()'s return val
  2020-11-17  8:30 ` Andrey Vagin
@ 2020-11-17 15:35   ` Hui Su
  0 siblings, 0 replies; 3+ messages in thread
From: Hui Su @ 2020-11-17 15:35 UTC (permalink / raw)
  To: Andrey Vagin, Christian Brauner, Serge E. Hallyn, Thomas Gleixner,
	linux-kernel

On Tue, Nov 17, 2020 at 12:30:26AM -0800, Andrey Vagin wrote:
> On Sun, Nov 15, 2020 at 10:36 AM Hui Su <sh_def@163.com> wrote:
> >
> > timens_on_fork() always return 0, and maybe not
> > need to judge the return value in copy_namespaces().
> 
> Thank you for cleaning this up. I think we can go even further and
> change timens_on_fork to return nothing:
> 
> -int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk)
> +void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk)
>  {
>         struct ns_common *nsc = &nsproxy->time_ns_for_children->ns;
>         struct time_namespace *ns = to_time_ns(nsc);
> 
>         /* create_new_namespaces() already incremented the ref counter */
>         if (nsproxy->time_ns == nsproxy->time_ns_for_children)
> -               return 0;
> +               return;
> 
>         get_time_ns(ns);
>         put_time_ns(nsproxy->time_ns);
>         nsproxy->time_ns = ns;
> 
>         timens_commit(tsk, ns);
> -
> -       return 0;
>  }
> 
> 
> >
> > Signed-off-by: Hui Su <sh_def@163.com>
> > ---
> >  kernel/nsproxy.c | 7 +------
> >  1 file changed, 1 insertion(+), 6 deletions(-)
> >
> > diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
> > index 12dd41b39a7f..e2e6c5dc433f 100644
> > --- a/kernel/nsproxy.c
> > +++ b/kernel/nsproxy.c
> > @@ -153,7 +153,6 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)
> >         struct nsproxy *old_ns = tsk->nsproxy;
> >         struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);
> >         struct nsproxy *new_ns;
> > -       int ret;
> >
> >         if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
> >                               CLONE_NEWPID | CLONE_NEWNET |
> > @@ -180,11 +179,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)
> >         if (IS_ERR(new_ns))
> >                 return  PTR_ERR(new_ns);
> >
> > -       ret = timens_on_fork(new_ns, tsk);
> > -       if (ret) {
> > -               free_nsproxy(new_ns);
> > -               return ret;
> > -       }
> > +       timens_on_fork(new_ns, tsk);
> >
> >         tsk->nsproxy = new_ns;
> >         return 0;
> > --
> > 2.29.0
> >
> >

Yeah, thank for your reply, Andrey.

I will resend PATCH V2 with makeing timens_on_fork() return nothing.

Thanks.


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

end of thread, other threads:[~2020-11-17 15:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-15 18:14 [PATCH] nsproxy: remove judge of timens_on_fork()'s return val Hui Su
2020-11-17  8:30 ` Andrey Vagin
2020-11-17 15:35   ` Hui Su

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