* proc: add nsfd mount option to allow mounting for pid namespaces other than the current
@ 2013-05-26 3:00 Stephen Mell
0 siblings, 0 replies; only message in thread
From: Stephen Mell @ 2013-05-26 3:00 UTC (permalink / raw)
To: linux-kernel
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;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-05-26 2:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-26 3:00 proc: add nsfd mount option to allow mounting for pid namespaces other than the current Stephen Mell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox