diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2011-06-18 07:00:10 -0700 |
---|---|---|
committer | Eric W. Biederman <ebiederm@aristanetworks.com> | 2011-08-11 17:51:54 -0500 |
commit | 4b8514148c47f4c0be7e5c1c52ea1ee5379202d5 (patch) | |
tree | f47094f179f7953d928a8f094d45b2e806ce5aab | |
parent | 467d31874f976c2db4b1a7a07d5b8bc878c00c73 (diff) | |
download | linux-user-ns-devel-4b8514148c47f4c0be7e5c1c52ea1ee5379202d5.tar.gz |
ns proc: Add support for the user namespace
Add the basic namespace file support, but do not
add support for setns.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
-rw-r--r-- | fs/proc/namespaces.c | 3 | ||||
-rw-r--r-- | include/linux/proc_fs.h | 1 | ||||
-rw-r--r-- | kernel/user_namespace.c | 24 |
3 files changed, 28 insertions, 0 deletions
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c index be177f702acbc9..acc6eafaa2d2d9 100644 --- a/fs/proc/namespaces.c +++ b/fs/proc/namespaces.c @@ -25,6 +25,9 @@ static const struct proc_ns_operations *ns_entries[] = { #ifdef CONFIG_IPC_NS &ipcns_operations, #endif +#ifdef CONFIG_USER_NS + &userns_operations, +#endif }; static const struct file_operations ns_file_operations = { diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 643b96c7a94f3c..a7624710b38a9f 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -251,6 +251,7 @@ struct proc_ns_operations { extern const struct proc_ns_operations netns_operations; extern const struct proc_ns_operations utsns_operations; extern const struct proc_ns_operations ipcns_operations; +extern const struct proc_ns_operations userns_operations; union proc_op { int (*proc_get_link)(struct inode *, struct path *); diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 9da289c34f22f1..0190a5bd814994 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c @@ -11,6 +11,7 @@ #include <linux/user_namespace.h> #include <linux/highuid.h> #include <linux/cred.h> +#include <linux/proc_fs.h> static struct kmem_cache *user_ns_cachep __read_mostly; @@ -135,3 +136,26 @@ static __init int user_namespaces_init(void) return 0; } module_init(user_namespaces_init); + +static void *userns_get(struct task_struct *task) +{ + return get_user_ns(task_cred_xxx(task, user)->user_ns); +} + +static void userns_put(void *ns) +{ + put_user_ns(ns); +} + +static int userns_install(struct nsproxy *nsproxy, void *ns) +{ + return -EINVAL; +} + +const struct proc_ns_operations userns_operations = { + .name = "user", + .type = CLONE_NEWNS, + .get = userns_get, + .put = userns_put, + .install = userns_install, +}; |