diff options
-rw-r--r-- | fs/namespace.c | 1 | ||||
-rw-r--r-- | fs/proc/inode.c | 6 | ||||
-rw-r--r-- | include/linux/ns_common.h | 3 | ||||
-rw-r--r-- | init/version.c | 3 | ||||
-rw-r--r-- | ipc/msgutil.c | 3 | ||||
-rw-r--r-- | ipc/namespace.c | 1 | ||||
-rw-r--r-- | kernel/nsproxy.c | 8 | ||||
-rw-r--r-- | kernel/pid.c | 3 | ||||
-rw-r--r-- | kernel/pid_namespace.c | 1 | ||||
-rw-r--r-- | kernel/user.c | 3 | ||||
-rw-r--r-- | kernel/user_namespace.c | 1 | ||||
-rw-r--r-- | kernel/utsname.c | 2 | ||||
-rw-r--r-- | net/core/net_namespace.c | 9 |
13 files changed, 34 insertions, 10 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 30738d200866..f815218f92d3 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -2672,6 +2672,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns) | |||
2672 | kfree(new_ns); | 2672 | kfree(new_ns); |
2673 | return ERR_PTR(ret); | 2673 | return ERR_PTR(ret); |
2674 | } | 2674 | } |
2675 | new_ns->ns.ops = &mntns_operations; | ||
2675 | new_ns->seq = atomic64_add_return(1, &mnt_ns_seq); | 2676 | new_ns->seq = atomic64_add_return(1, &mnt_ns_seq); |
2676 | atomic_set(&new_ns->count, 1); | 2677 | atomic_set(&new_ns->count, 1); |
2677 | new_ns->root = NULL; | 2678 | new_ns->root = NULL; |
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 43b703c6cd3b..a212996e0987 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
@@ -32,7 +32,6 @@ static void proc_evict_inode(struct inode *inode) | |||
32 | { | 32 | { |
33 | struct proc_dir_entry *de; | 33 | struct proc_dir_entry *de; |
34 | struct ctl_table_header *head; | 34 | struct ctl_table_header *head; |
35 | const struct proc_ns_operations *ns_ops; | ||
36 | struct ns_common *ns; | 35 | struct ns_common *ns; |
37 | 36 | ||
38 | truncate_inode_pages_final(&inode->i_data); | 37 | truncate_inode_pages_final(&inode->i_data); |
@@ -51,10 +50,9 @@ static void proc_evict_inode(struct inode *inode) | |||
51 | sysctl_head_put(head); | 50 | sysctl_head_put(head); |
52 | } | 51 | } |
53 | /* Release any associated namespace */ | 52 | /* Release any associated namespace */ |
54 | ns_ops = PROC_I(inode)->ns.ns_ops; | ||
55 | ns = PROC_I(inode)->ns.ns; | 53 | ns = PROC_I(inode)->ns.ns; |
56 | if (ns_ops && ns) | 54 | if (ns && ns->ops) |
57 | ns_ops->put(ns); | 55 | ns->ops->put(ns); |
58 | } | 56 | } |
59 | 57 | ||
60 | static struct kmem_cache * proc_inode_cachep; | 58 | static struct kmem_cache * proc_inode_cachep; |
diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h index e7db1cd54047..ce23cf4bbe69 100644 --- a/include/linux/ns_common.h +++ b/include/linux/ns_common.h | |||
@@ -1,7 +1,10 @@ | |||
1 | #ifndef _LINUX_NS_COMMON_H | 1 | #ifndef _LINUX_NS_COMMON_H |
2 | #define _LINUX_NS_COMMON_H | 2 | #define _LINUX_NS_COMMON_H |
3 | 3 | ||
4 | struct proc_ns_operations; | ||
5 | |||
4 | struct ns_common { | 6 | struct ns_common { |
7 | const struct proc_ns_operations *ops; | ||
5 | unsigned int inum; | 8 | unsigned int inum; |
6 | }; | 9 | }; |
7 | 10 | ||
diff --git a/init/version.c b/init/version.c index e23dbdabb26b..fe41a63efed6 100644 --- a/init/version.c +++ b/init/version.c | |||
@@ -36,6 +36,9 @@ struct uts_namespace init_uts_ns = { | |||
36 | }, | 36 | }, |
37 | .user_ns = &init_user_ns, | 37 | .user_ns = &init_user_ns, |
38 | .ns.inum = PROC_UTS_INIT_INO, | 38 | .ns.inum = PROC_UTS_INIT_INO, |
39 | #ifdef CONFIG_UTS_NS | ||
40 | .ns.ops = &utsns_operations, | ||
41 | #endif | ||
39 | }; | 42 | }; |
40 | EXPORT_SYMBOL_GPL(init_uts_ns); | 43 | EXPORT_SYMBOL_GPL(init_uts_ns); |
41 | 44 | ||
diff --git a/ipc/msgutil.c b/ipc/msgutil.c index 5930471a2902..2b491590ebab 100644 --- a/ipc/msgutil.c +++ b/ipc/msgutil.c | |||
@@ -32,6 +32,9 @@ struct ipc_namespace init_ipc_ns = { | |||
32 | .count = ATOMIC_INIT(1), | 32 | .count = ATOMIC_INIT(1), |
33 | .user_ns = &init_user_ns, | 33 | .user_ns = &init_user_ns, |
34 | .ns.inum = PROC_IPC_INIT_INO, | 34 | .ns.inum = PROC_IPC_INIT_INO, |
35 | #ifdef CONFIG_IPC_NS | ||
36 | .ns.ops = &ipcns_operations, | ||
37 | #endif | ||
35 | }; | 38 | }; |
36 | 39 | ||
37 | atomic_t nr_ipc_ns = ATOMIC_INIT(1); | 40 | atomic_t nr_ipc_ns = ATOMIC_INIT(1); |
diff --git a/ipc/namespace.c b/ipc/namespace.c index bcdd7a5c122a..382e2aa42d8a 100644 --- a/ipc/namespace.c +++ b/ipc/namespace.c | |||
@@ -31,6 +31,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns, | |||
31 | kfree(ns); | 31 | kfree(ns); |
32 | return ERR_PTR(err); | 32 | return ERR_PTR(err); |
33 | } | 33 | } |
34 | ns->ns.ops = &ipcns_operations; | ||
34 | 35 | ||
35 | atomic_set(&ns->count, 1); | 36 | atomic_set(&ns->count, 1); |
36 | err = mq_init_ns(ns); | 37 | err = mq_init_ns(ns); |
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index ef42d0ab3115..87c37221cb7f 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c | |||
@@ -220,11 +220,11 @@ void exit_task_namespaces(struct task_struct *p) | |||
220 | 220 | ||
221 | SYSCALL_DEFINE2(setns, int, fd, int, nstype) | 221 | SYSCALL_DEFINE2(setns, int, fd, int, nstype) |
222 | { | 222 | { |
223 | const struct proc_ns_operations *ops; | ||
224 | struct task_struct *tsk = current; | 223 | struct task_struct *tsk = current; |
225 | struct nsproxy *new_nsproxy; | 224 | struct nsproxy *new_nsproxy; |
226 | struct proc_ns *ei; | 225 | struct proc_ns *ei; |
227 | struct file *file; | 226 | struct file *file; |
227 | struct ns_common *ns; | ||
228 | int err; | 228 | int err; |
229 | 229 | ||
230 | file = proc_ns_fget(fd); | 230 | file = proc_ns_fget(fd); |
@@ -233,8 +233,8 @@ SYSCALL_DEFINE2(setns, int, fd, int, nstype) | |||
233 | 233 | ||
234 | err = -EINVAL; | 234 | err = -EINVAL; |
235 | ei = get_proc_ns(file_inode(file)); | 235 | ei = get_proc_ns(file_inode(file)); |
236 | ops = ei->ns_ops; | 236 | ns = ei->ns; |
237 | if (nstype && (ops->type != nstype)) | 237 | if (nstype && (ns->ops->type != nstype)) |
238 | goto out; | 238 | goto out; |
239 | 239 | ||
240 | new_nsproxy = create_new_namespaces(0, tsk, current_user_ns(), tsk->fs); | 240 | new_nsproxy = create_new_namespaces(0, tsk, current_user_ns(), tsk->fs); |
@@ -243,7 +243,7 @@ SYSCALL_DEFINE2(setns, int, fd, int, nstype) | |||
243 | goto out; | 243 | goto out; |
244 | } | 244 | } |
245 | 245 | ||
246 | err = ops->install(new_nsproxy, ei->ns); | 246 | err = ns->ops->install(new_nsproxy, ns); |
247 | if (err) { | 247 | if (err) { |
248 | free_nsproxy(new_nsproxy); | 248 | free_nsproxy(new_nsproxy); |
249 | goto out; | 249 | goto out; |
diff --git a/kernel/pid.c b/kernel/pid.c index 3650698cf1dc..c17a993a4d2a 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -80,6 +80,9 @@ struct pid_namespace init_pid_ns = { | |||
80 | .child_reaper = &init_task, | 80 | .child_reaper = &init_task, |
81 | .user_ns = &init_user_ns, | 81 | .user_ns = &init_user_ns, |
82 | .ns.inum = PROC_PID_INIT_INO, | 82 | .ns.inum = PROC_PID_INIT_INO, |
83 | #ifdef CONFIG_PID_NS | ||
84 | .ns.ops = &pidns_operations, | ||
85 | #endif | ||
83 | }; | 86 | }; |
84 | EXPORT_SYMBOL_GPL(init_pid_ns); | 87 | EXPORT_SYMBOL_GPL(init_pid_ns); |
85 | 88 | ||
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index 5aa9158a84d5..e1bafe3b47bb 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c | |||
@@ -108,6 +108,7 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns | |||
108 | err = ns_alloc_inum(&ns->ns); | 108 | err = ns_alloc_inum(&ns->ns); |
109 | if (err) | 109 | if (err) |
110 | goto out_free_map; | 110 | goto out_free_map; |
111 | ns->ns.ops = &pidns_operations; | ||
111 | 112 | ||
112 | kref_init(&ns->kref); | 113 | kref_init(&ns->kref); |
113 | ns->level = level; | 114 | ns->level = level; |
diff --git a/kernel/user.c b/kernel/user.c index a7ca84bad8e6..69b800aebf13 100644 --- a/kernel/user.c +++ b/kernel/user.c | |||
@@ -51,6 +51,9 @@ struct user_namespace init_user_ns = { | |||
51 | .owner = GLOBAL_ROOT_UID, | 51 | .owner = GLOBAL_ROOT_UID, |
52 | .group = GLOBAL_ROOT_GID, | 52 | .group = GLOBAL_ROOT_GID, |
53 | .ns.inum = PROC_USER_INIT_INO, | 53 | .ns.inum = PROC_USER_INIT_INO, |
54 | #ifdef CONFIG_USER_NS | ||
55 | .ns.ops = &userns_operations, | ||
56 | #endif | ||
54 | #ifdef CONFIG_PERSISTENT_KEYRINGS | 57 | #ifdef CONFIG_PERSISTENT_KEYRINGS |
55 | .persistent_keyring_register_sem = | 58 | .persistent_keyring_register_sem = |
56 | __RWSEM_INITIALIZER(init_user_ns.persistent_keyring_register_sem), | 59 | __RWSEM_INITIALIZER(init_user_ns.persistent_keyring_register_sem), |
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 6bf8177768e5..1491ad00388f 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c | |||
@@ -91,6 +91,7 @@ int create_user_ns(struct cred *new) | |||
91 | kmem_cache_free(user_ns_cachep, ns); | 91 | kmem_cache_free(user_ns_cachep, ns); |
92 | return ret; | 92 | return ret; |
93 | } | 93 | } |
94 | ns->ns.ops = &userns_operations; | ||
94 | 95 | ||
95 | atomic_set(&ns->count, 1); | 96 | atomic_set(&ns->count, 1); |
96 | /* Leave the new->user_ns reference with the new user namespace. */ | 97 | /* Leave the new->user_ns reference with the new user namespace. */ |
diff --git a/kernel/utsname.c b/kernel/utsname.c index c2a2b321d88a..831ea7108232 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c | |||
@@ -48,6 +48,8 @@ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns, | |||
48 | return ERR_PTR(err); | 48 | return ERR_PTR(err); |
49 | } | 49 | } |
50 | 50 | ||
51 | ns->ns.ops = &utsns_operations; | ||
52 | |||
51 | down_read(&uts_sem); | 53 | down_read(&uts_sem); |
52 | memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); | 54 | memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); |
53 | ns->user_ns = get_user_ns(user_ns); | 55 | ns->user_ns = get_user_ns(user_ns); |
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index da775f53f3fd..4d4acaf7b498 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c | |||
@@ -339,6 +339,7 @@ struct net *get_net_ns_by_fd(int fd) | |||
339 | { | 339 | { |
340 | struct proc_ns *ei; | 340 | struct proc_ns *ei; |
341 | struct file *file; | 341 | struct file *file; |
342 | struct ns_common *ns; | ||
342 | struct net *net; | 343 | struct net *net; |
343 | 344 | ||
344 | file = proc_ns_fget(fd); | 345 | file = proc_ns_fget(fd); |
@@ -346,8 +347,9 @@ struct net *get_net_ns_by_fd(int fd) | |||
346 | return ERR_CAST(file); | 347 | return ERR_CAST(file); |
347 | 348 | ||
348 | ei = get_proc_ns(file_inode(file)); | 349 | ei = get_proc_ns(file_inode(file)); |
349 | if (ei->ns_ops == &netns_operations) | 350 | ns = ei->ns; |
350 | net = get_net(container_of(ei->ns, struct net, ns)); | 351 | if (ns->ops == &netns_operations) |
352 | net = get_net(container_of(ns, struct net, ns)); | ||
351 | else | 353 | else |
352 | net = ERR_PTR(-EINVAL); | 354 | net = ERR_PTR(-EINVAL); |
353 | 355 | ||
@@ -386,6 +388,9 @@ EXPORT_SYMBOL_GPL(get_net_ns_by_pid); | |||
386 | 388 | ||
387 | static __net_init int net_ns_net_init(struct net *net) | 389 | static __net_init int net_ns_net_init(struct net *net) |
388 | { | 390 | { |
391 | #ifdef CONFIG_NET_NS | ||
392 | net->ns.ops = &netns_operations; | ||
393 | #endif | ||
389 | return ns_alloc_inum(&net->ns); | 394 | return ns_alloc_inum(&net->ns); |
390 | } | 395 | } |
391 | 396 | ||