diff options
Diffstat (limited to 'kernel/utsname.c')
-rw-r--r-- | kernel/utsname.c | 15 |
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 | ||
91 | static inline struct uts_namespace *to_uts_ns(struct ns_common *ns) | ||
92 | { | ||
93 | return container_of(ns, struct uts_namespace, ns); | ||
94 | } | ||
95 | |||
91 | static void *utsns_get(struct task_struct *task) | 96 | static 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 | ||
107 | static void utsns_put(void *ns) | 112 | static void utsns_put(void *ns) |
108 | { | 113 | { |
109 | put_uts_ns(ns); | 114 | put_uts_ns(to_uts_ns(ns)); |
110 | } | 115 | } |
111 | 116 | ||
112 | static int utsns_install(struct nsproxy *nsproxy, void *new) | 117 | static 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 | ||
126 | static unsigned int utsns_inum(void *vp) | 131 | static 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 | ||
133 | const struct proc_ns_operations utsns_operations = { | 136 | const struct proc_ns_operations utsns_operations = { |