diff options
Diffstat (limited to 'kernel/utsname.c')
-rw-r--r-- | kernel/utsname.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/kernel/utsname.c b/kernel/utsname.c index fdc619eb61ef..f6336d51d64c 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c | |||
@@ -36,11 +36,18 @@ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns, | |||
36 | struct uts_namespace *old_ns) | 36 | struct uts_namespace *old_ns) |
37 | { | 37 | { |
38 | struct uts_namespace *ns; | 38 | struct uts_namespace *ns; |
39 | int err; | ||
39 | 40 | ||
40 | ns = create_uts_ns(); | 41 | ns = create_uts_ns(); |
41 | if (!ns) | 42 | if (!ns) |
42 | return ERR_PTR(-ENOMEM); | 43 | return ERR_PTR(-ENOMEM); |
43 | 44 | ||
45 | err = proc_alloc_inum(&ns->proc_inum); | ||
46 | if (err) { | ||
47 | kfree(ns); | ||
48 | return ERR_PTR(err); | ||
49 | } | ||
50 | |||
44 | down_read(&uts_sem); | 51 | down_read(&uts_sem); |
45 | memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); | 52 | memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); |
46 | ns->user_ns = get_user_ns(user_ns); | 53 | ns->user_ns = get_user_ns(user_ns); |
@@ -77,6 +84,7 @@ void free_uts_ns(struct kref *kref) | |||
77 | 84 | ||
78 | ns = container_of(kref, struct uts_namespace, kref); | 85 | ns = container_of(kref, struct uts_namespace, kref); |
79 | put_user_ns(ns->user_ns); | 86 | put_user_ns(ns->user_ns); |
87 | proc_free_inum(ns->proc_inum); | ||
80 | kfree(ns); | 88 | kfree(ns); |
81 | } | 89 | } |
82 | 90 | ||
@@ -114,11 +122,18 @@ static int utsns_install(struct nsproxy *nsproxy, void *new) | |||
114 | return 0; | 122 | return 0; |
115 | } | 123 | } |
116 | 124 | ||
125 | static unsigned int utsns_inum(void *vp) | ||
126 | { | ||
127 | struct uts_namespace *ns = vp; | ||
128 | |||
129 | return ns->proc_inum; | ||
130 | } | ||
131 | |||
117 | const struct proc_ns_operations utsns_operations = { | 132 | const struct proc_ns_operations utsns_operations = { |
118 | .name = "uts", | 133 | .name = "uts", |
119 | .type = CLONE_NEWUTS, | 134 | .type = CLONE_NEWUTS, |
120 | .get = utsns_get, | 135 | .get = utsns_get, |
121 | .put = utsns_put, | 136 | .put = utsns_put, |
122 | .install = utsns_install, | 137 | .install = utsns_install, |
138 | .inum = utsns_inum, | ||
123 | }; | 139 | }; |
124 | |||