From: Stephen Mell <sub.atomic.fusion@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: proc: add nsfd mount option to allow mounting for pid namespaces other than the current
Date: Sun, 26 May 2013 03:00:05 +0000 [thread overview]
Message-ID: <1823955.4fAi8iUinf@pegasus> (raw)
From: Stephen Mell <sub.atomic.fusion@gmail.com>
Currently, there is no userspace method to mount proc for a pid namespace other than the current one. In light of the new namespace filedescriptors, this patch adds a mount option to use the namespace represented by the specified filedescriptor instead of the current pid namespace. This patch depends on "proc: move proc mount options out of pid_namespace".
Signed-off-by: Stephen Mell <sub.atomic.fusion@gmail.com>
---
fs/proc/root.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 5a2b6ff..6a9a46d 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -39,10 +39,11 @@ static int proc_set_super(struct super_block *sb, void *data)
}
enum {
- Opt_gid, Opt_hidepid, Opt_err,
+ Opt_nsfd, Opt_gid, Opt_hidepid, Opt_err,
};
static const match_table_t tokens = {
+ {Opt_nsfd, "nsfd=%u"},
{Opt_hidepid, "hidepid=%u"},
{Opt_gid, "gid=%u"},
{Opt_err, NULL},
@@ -53,6 +54,8 @@ static int proc_parse_options(char *options, struct proc_sb_info *fsi)
char *p;
substring_t args[MAX_OPT_ARGS];
int option;
+ struct proc_ns *ei;
+ struct file *file;
if (!options)
return 1;
@@ -65,6 +68,24 @@ static int proc_parse_options(char *options, struct proc_sb_info *fsi)
args[0].to = args[0].from = NULL;
token = match_token(p, tokens, args);
switch (token) {
+ case Opt_nsfd:
+ if (match_int(&args[0], &option))
+ return 0;
+ file = proc_ns_fget(option);
+ if (IS_ERR(file)) {
+ pr_err("proc: nsfd value must refer to a pid namespace.\n");
+ return 0;
+ }
+ ei = get_proc_ns(file_inode(file));
+ if (!(ei->ns_ops->type & CLONE_NEWPID)) {
+ pr_err("proc: nsfd value must refer to a pid namespace.\n");
+ return 0;
+ }
+ if (fsi->ns)
+ put_pid_ns(fsi->ns);
+ fsi->ns = ei->ns;
+ get_pid_ns(fsi->ns);
+ break;
case Opt_gid:
if (match_int(&args[0], &option))
return 0;
reply other threads:[~2013-05-26 2:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1823955.4fAi8iUinf@pegasus \
--to=sub.atomic.fusion@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.