aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/utsname.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/utsname.c')
-rw-r--r--kernel/utsname.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/kernel/utsname.c b/kernel/utsname.c
index b1cd00b828f2..1917f74be8ec 100644
--- a/kernel/utsname.c
+++ b/kernel/utsname.c
@@ -88,6 +88,11 @@ void free_uts_ns(struct kref *kref)
88 kfree(ns); 88 kfree(ns);
89} 89}
90 90
91static inline struct uts_namespace *to_uts_ns(struct ns_common *ns)
92{
93 return container_of(ns, struct uts_namespace, ns);
94}
95
91static void *utsns_get(struct task_struct *task) 96static void *utsns_get(struct task_struct *task)
92{ 97{
93 struct uts_namespace *ns = NULL; 98 struct uts_namespace *ns = NULL;
@@ -101,17 +106,17 @@ static void *utsns_get(struct task_struct *task)
101 } 106 }
102 task_unlock(task); 107 task_unlock(task);
103 108
104 return ns; 109 return ns ? &ns->ns : NULL;
105} 110}
106 111
107static void utsns_put(void *ns) 112static void utsns_put(void *ns)
108{ 113{
109 put_uts_ns(ns); 114 put_uts_ns(to_uts_ns(ns));
110} 115}
111 116
112static int utsns_install(struct nsproxy *nsproxy, void *new) 117static int utsns_install(struct nsproxy *nsproxy, void *new)
113{ 118{
114 struct uts_namespace *ns = new; 119 struct uts_namespace *ns = to_uts_ns(new);
115 120
116 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) || 121 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) ||
117 !ns_capable(current_user_ns(), CAP_SYS_ADMIN)) 122 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
@@ -125,9 +130,7 @@ static int utsns_install(struct nsproxy *nsproxy, void *new)
125 130
126static unsigned int utsns_inum(void *vp) 131static unsigned int utsns_inum(void *vp)
127{ 132{
128 struct uts_namespace *ns = vp; 133 return ((struct ns_common *)vp)->inum;
129
130 return ns->ns.inum;
131} 134}
132 135
133const struct proc_ns_operations utsns_operations = { 136const struct proc_ns_operations utsns_operations = {