aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/proc/namespaces.c3
-rw-r--r--include/linux/proc_fs.h1
-rw-r--r--kernel/utsname.c39
3 files changed, 43 insertions, 0 deletions
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index dcbd483e9915..b017181f1273 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -19,6 +19,9 @@ static const struct proc_ns_operations *ns_entries[] = {
19#ifdef CONFIG_NET_NS 19#ifdef CONFIG_NET_NS
20 &netns_operations, 20 &netns_operations,
21#endif 21#endif
22#ifdef CONFIG_UTS_NS
23 &utsns_operations,
24#endif
22}; 25};
23 26
24static const struct file_operations ns_file_operations = { 27static const struct file_operations ns_file_operations = {
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 62126ec6ede9..52aa89df8a6d 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -266,6 +266,7 @@ struct proc_ns_operations {
266 int (*install)(struct nsproxy *nsproxy, void *ns); 266 int (*install)(struct nsproxy *nsproxy, void *ns);
267}; 267};
268extern const struct proc_ns_operations netns_operations; 268extern const struct proc_ns_operations netns_operations;
269extern const struct proc_ns_operations utsns_operations;
269 270
270union proc_op { 271union proc_op {
271 int (*proc_get_link)(struct inode *, struct path *); 272 int (*proc_get_link)(struct inode *, struct path *);
diff --git a/kernel/utsname.c b/kernel/utsname.c
index 44646179eaba..bff131b9510a 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
19static struct uts_namespace *create_uts_ns(void) 20static 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
84static 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
100static void utsns_put(void *ns)
101{
102 put_uts_ns(ns);
103}
104
105static 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
113const 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