From: Andrew Morton <akpm@linux-foundation.org>
To: Yunhui Cui <cuiyunhui@bytedance.com>
Cc: keescook@chromium.org, brauner@kernel.org, jeffxu@google.com,
frederic@kernel.org, mcgrof@kernel.org, cyphar@cyphar.com,
rongtao@cestc.cn, linux-kernel@vger.kernel.org,
"Eric W. Biederman" <ebiederm@xmission.com>
Subject: Re: [PATCH] pid_ns: support pidns switching between sibling
Date: Wed, 11 Oct 2023 10:22:31 -0700 [thread overview]
Message-ID: <20231011102231.5464c68ddd9e89deb9aa0ca9@linux-foundation.org> (raw)
In-Reply-To: <20231011065446.53034-1-cuiyunhui@bytedance.com>
On Wed, 11 Oct 2023 14:54:46 +0800 Yunhui Cui <cuiyunhui@bytedance.com> wrote:
> In the scenario of container acceleration, when a target pstree
> is cloned from a temp pstree, we hope that the cloned process is
> inherently in the target's pid namespace.
> Examples of what we expected:
>
> /* switch to target ns first. */
> setns(target_ns, CLONE_NEWPID);
> if(!fork()) {
> /* Child */
> ...
> }
> /* switch back */
> setns(temp_ns, CLONE_NEWPID);
>
> However, it is limited by the existing implementation, CAP_SYS_ADMIN
> has been checked in pidns_install(), so remove the limitation that only
> by traversing parent can switch pidns.
>
(cc Eric)
> --- a/kernel/pid_namespace.c
> +++ b/kernel/pid_namespace.c
> @@ -389,7 +389,7 @@ static int pidns_install(struct nsset *nsset, struct ns_common *ns)
> {
> struct nsproxy *nsproxy = nsset->nsproxy;
> struct pid_namespace *active = task_active_pid_ns(current);
> - struct pid_namespace *ancestor, *new = to_pid_ns(ns);
> + struct pid_namespace *new = to_pid_ns(ns);
>
> if (!ns_capable(new->user_ns, CAP_SYS_ADMIN) ||
> !ns_capable(nsset->cred->user_ns, CAP_SYS_ADMIN))
> @@ -406,12 +406,6 @@ static int pidns_install(struct nsset *nsset, struct ns_common *ns)
> if (new->level < active->level)
> return -EINVAL;
>
> - ancestor = new;
> - while (ancestor->level > active->level)
> - ancestor = ancestor->parent;
> - if (ancestor != active)
> - return -EINVAL;
> -
> put_pid_ns(nsproxy->pid_ns_for_children);
> nsproxy->pid_ns_for_children = get_pid_ns(new);
> return 0;
> --
> 2.20.1
next prev parent reply other threads:[~2023-10-11 17:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-11 6:54 Yunhui Cui
2023-10-11 17:22 ` Andrew Morton [this message]
2023-10-12 3:30 ` Eric W. Biederman
2023-10-13 2:44 ` [External] " yunhui cui
2023-10-13 8:55 ` yunhui cui
2023-10-13 13:03 ` Eric W. Biederman
2023-10-14 3:41 ` yunhui cui
2023-10-14 4:21 ` Eric W. Biederman
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=20231011102231.5464c68ddd9e89deb9aa0ca9@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=cuiyunhui@bytedance.com \
--cc=cyphar@cyphar.com \
--cc=ebiederm@xmission.com \
--cc=frederic@kernel.org \
--cc=jeffxu@google.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=rongtao@cestc.cn \
/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
all inboxes | Powered by JetHome®