public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Discuss the implementation of pidns_install()
       [not found] <CAEEQ3wnfOOpKAKGt07cFv1Du-NaFOzX_=yeQZfD6VNojpPFTqA@mail.gmail.com>
@ 2023-10-09 20:08 ` Kees Cook
  2023-10-10  3:29   ` [External] " yunhui cui
  0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2023-10-09 20:08 UTC (permalink / raw)
  To: yunhui cui, brauner
  Cc: jeffxu, akpm, cyphar, mcgrof, frederic,
	lkml - Kernel Mailing List

On Wed, Sep 20, 2023 at 05:37:20PM +0800, yunhui cui wrote:
> Hi Kees, jeff, Andrew, Christian,
> 
> We hope that containers at the same level can also switch pid namespace.
> To fork() the entire pstree of a container, we need to switch from the pid
> namespace of the template container to the  target container's pid
> namespace. But it is blocked by the following code:
> 
> ...
>         while (ancestor->level > active->level)
>                 ancestor = ancestor->parent;
>         if (ancestor != active)
>                 return -EINVAL;
> ...
> 
> Can we give this code permission, such as CAP_SYS_ADMIN ..., so that those
> with this permission can switch to sibling pid namespace. Rather than just
> parent, parent ...
> 
> Do you think this plan is okay?  Or can you give me some suggestions?

I'll defer to Christian on this, but it seems like moving processes
sideways is kind of unexpected. I agree it'd need privilege if we did
it, though.

-- 
Kees Cook

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

* Re: [External] Re: Discuss the implementation of pidns_install()
  2023-10-09 20:08 ` Discuss the implementation of pidns_install() Kees Cook
@ 2023-10-10  3:29   ` yunhui cui
  2023-10-11  1:46     ` yunhui cui
  0 siblings, 1 reply; 3+ messages in thread
From: yunhui cui @ 2023-10-10  3:29 UTC (permalink / raw)
  To: Kees Cook
  Cc: brauner, jeffxu, akpm, cyphar, mcgrof, frederic,
	lkml - Kernel Mailing List

Hi Kees Cook,

On Tue, Oct 10, 2023 at 4:08 AM Kees Cook <keescook@chromium.org> wrote:
>
> On Wed, Sep 20, 2023 at 05:37:20PM +0800, yunhui cui wrote:
> > Hi Kees, jeff, Andrew, Christian,
> >
> > We hope that containers at the same level can also switch pid namespace.
> > To fork() the entire pstree of a container, we need to switch from the pid
> > namespace of the template container to the  target container's pid
> > namespace. But it is blocked by the following code:
> >
> > ...
> >         while (ancestor->level > active->level)
> >                 ancestor = ancestor->parent;
> >         if (ancestor != active)
> >                 return -EINVAL;
> > ...
> >
> > Can we give this code permission, such as CAP_SYS_ADMIN ..., so that those
> > with this permission can switch to sibling pid namespace. Rather than just
> > parent, parent ...
> >
> > Do you think this plan is okay?  Or can you give me some suggestions?
>
> I'll defer to Christian on this, but it seems like moving processes
> sideways is kind of unexpected. I agree it'd need privilege if we did
> it, though.
>
>

I'll defer to Christian on this, but it seems like moving processes
sideways is kind of unexpected. I agree it'd need privilege if we did
it, though.

Thanks for your suggestion, my plan is to give this code SYS_ADMIN permissions.

CAP_SYS_ADMIN has been checked in pidns_install(), as follows:
static int pidns_install(struct nsproxy *nsproxy, struct ns_common *ns)
{
...
if (!ns_capable(new->user_ns, CAP_SYS_ADMIN) ||
!ns_capable(current_user_ns(), CAP_SYS_ADMIN))
return -EPERM;
...
}

So can I delete this code:
ancestor = new;
while (ancestor->level > active->level)
ancestor = ancestor->parent;
if (ancestor != active)
return -EINVAL;

Thanks,
Yunhui

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

* Re: [External] Re: Discuss the implementation of pidns_install()
  2023-10-10  3:29   ` [External] " yunhui cui
@ 2023-10-11  1:46     ` yunhui cui
  0 siblings, 0 replies; 3+ messages in thread
From: yunhui cui @ 2023-10-11  1:46 UTC (permalink / raw)
  To: Kees Cook
  Cc: brauner, jeffxu, akpm, cyphar, mcgrof, frederic,
	lkml - Kernel Mailing List

Hi Christian,

On Tue, Oct 10, 2023 at 11:29 AM yunhui cui <cuiyunhui@bytedance.com> wrote:
>
> Hi Kees Cook,
>
> On Tue, Oct 10, 2023 at 4:08 AM Kees Cook <keescook@chromium.org> wrote:
> >
> > On Wed, Sep 20, 2023 at 05:37:20PM +0800, yunhui cui wrote:
> > > Hi Kees, jeff, Andrew, Christian,
> > >
> > > We hope that containers at the same level can also switch pid namespace.
> > > To fork() the entire pstree of a container, we need to switch from the pid
> > > namespace of the template container to the  target container's pid
> > > namespace. But it is blocked by the following code:
> > >
> > > ...
> > >         while (ancestor->level > active->level)
> > >                 ancestor = ancestor->parent;
> > >         if (ancestor != active)
> > >                 return -EINVAL;
> > > ...
> > >
> > > Can we give this code permission, such as CAP_SYS_ADMIN ..., so that those
> > > with this permission can switch to sibling pid namespace. Rather than just
> > > parent, parent ...
> > >
> > > Do you think this plan is okay?  Or can you give me some suggestions?
> >
> > I'll defer to Christian on this, but it seems like moving processes
> > sideways is kind of unexpected. I agree it'd need privilege if we did
> > it, though.
> >
> >
>
> I'll defer to Christian on this, but it seems like moving processes
> sideways is kind of unexpected. I agree it'd need privilege if we did
> it, though.
>
> Thanks for your suggestion, my plan is to give this code SYS_ADMIN permissions.
>
> CAP_SYS_ADMIN has been checked in pidns_install(), as follows:
> static int pidns_install(struct nsproxy *nsproxy, struct ns_common *ns)
> {
> ...
> if (!ns_capable(new->user_ns, CAP_SYS_ADMIN) ||
> !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
> return -EPERM;
> ...
> }
>
> So can I delete this code:
> ancestor = new;
> while (ancestor->level > active->level)
> ancestor = ancestor->parent;
> if (ancestor != active)
> return -EINVAL;
>
> Thanks,
> Yunhui

Could you help me look into this issue?

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

end of thread, other threads:[~2023-10-11  1:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAEEQ3wnfOOpKAKGt07cFv1Du-NaFOzX_=yeQZfD6VNojpPFTqA@mail.gmail.com>
2023-10-09 20:08 ` Discuss the implementation of pidns_install() Kees Cook
2023-10-10  3:29   ` [External] " yunhui cui
2023-10-11  1:46     ` yunhui cui

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