diff options
Diffstat (limited to 'kernel/utsname.c')
| -rw-r--r-- | kernel/utsname.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/kernel/utsname.c b/kernel/utsname.c index 44646179eab..bff131b9510 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <linux/err.h> | 15 | #include <linux/err.h> |
| 16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
| 17 | #include <linux/user_namespace.h> | 17 | #include <linux/user_namespace.h> |
| 18 | #include <linux/proc_fs.h> | ||
| 18 | 19 | ||
| 19 | static struct uts_namespace *create_uts_ns(void) | 20 | static struct uts_namespace *create_uts_ns(void) |
| 20 | { | 21 | { |
| @@ -79,3 +80,41 @@ void free_uts_ns(struct kref *kref) | |||
| 79 | put_user_ns(ns->user_ns); | 80 | put_user_ns(ns->user_ns); |
| 80 | kfree(ns); | 81 | kfree(ns); |
| 81 | } | 82 | } |
| 83 | |||
| 84 | static void *utsns_get(struct task_struct *task) | ||
| 85 | { | ||
| 86 | struct uts_namespace *ns = NULL; | ||
| 87 | struct nsproxy *nsproxy; | ||
| 88 | |||
| 89 | rcu_read_lock(); | ||
| 90 | nsproxy = task_nsproxy(task); | ||
| 91 | if (nsproxy) { | ||
| 92 | ns = nsproxy->uts_ns; | ||
| 93 | get_uts_ns(ns); | ||
| 94 | } | ||
| 95 | rcu_read_unlock(); | ||
| 96 | |||
| 97 | return ns; | ||
| 98 | } | ||
| 99 | |||
| 100 | static void utsns_put(void *ns) | ||
| 101 | { | ||
| 102 | put_uts_ns(ns); | ||
| 103 | } | ||
| 104 | |||
| 105 | static int utsns_install(struct nsproxy *nsproxy, void *ns) | ||
| 106 | { | ||
| 107 | get_uts_ns(ns); | ||
| 108 | put_uts_ns(nsproxy->uts_ns); | ||
| 109 | nsproxy->uts_ns = ns; | ||
| 110 | return 0; | ||
| 111 | } | ||
| 112 | |||
| 113 | const struct proc_ns_operations utsns_operations = { | ||
| 114 | .name = "uts", | ||
| 115 | .type = CLONE_NEWUTS, | ||
| 116 | .get = utsns_get, | ||
| 117 | .put = utsns_put, | ||
| 118 | .install = utsns_install, | ||
| 119 | }; | ||
| 120 | |||
