lkml.org 
[lkml]   [2013]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subjectproc: add nsfd mount option to allow mounting for pid namespaces other than the current
Date
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;


\
 
 \ /
  Last update: 2013-05-26 05:21    [W:0.032 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site