diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-16 18:53:03 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-16 18:53:03 -0500 |
commit | 603ba7e41bf5d405aba22294af5d075d8898176d (patch) | |
tree | fb9cf0b7c4912b5105f7da5efdd204cd0e66c8db /kernel/pid_namespace.c | |
parent | 31f48fc8f226f968d6e6b9b9718abe8e16c51fe8 (diff) | |
parent | 93fe74b2e2b5d266d630f0c3f8287efcbe6ecd10 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs pile #2 from Al Viro:
"Next pile (and there'll be one or two more).
The large piece in this one is getting rid of /proc/*/ns/* weirdness;
among other things, it allows to (finally) make nameidata completely
opaque outside of fs/namei.c, making for easier further cleanups in
there"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
coda_venus_readdir(): use file_inode()
fs/namei.c: fold link_path_walk() call into path_init()
path_init(): don't bother with LOOKUP_PARENT in argument
fs/namei.c: new helper (path_cleanup())
path_init(): store the "base" pointer to file in nameidata itself
make default ->i_fop have ->open() fail with ENXIO
make nameidata completely opaque outside of fs/namei.c
kill proc_ns completely
take the targets of /proc/*/ns/* symlinks to separate fs
bury struct proc_ns in fs/proc
copy address of proc_ns_ops into ns_common
new helpers: ns_alloc_inum/ns_free_inum
make proc_ns_operations work with struct ns_common * instead of void *
switch the rest of proc_ns_operations to working with &...->ns
netns: switch ->get()/->put()/->install()/->inum() to working with &net->ns
make mntns ->get()/->put()/->install()/->inum() work with &mnt_ns->ns
common object embedded into various struct ....ns
Diffstat (limited to 'kernel/pid_namespace.c')
-rw-r--r-- | kernel/pid_namespace.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index bc6d6a89b6e6..a65ba137fd15 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c | |||
@@ -105,9 +105,10 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns | |||
105 | if (ns->pid_cachep == NULL) | 105 | if (ns->pid_cachep == NULL) |
106 | goto out_free_map; | 106 | goto out_free_map; |
107 | 107 | ||
108 | err = proc_alloc_inum(&ns->proc_inum); | 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; |
@@ -142,7 +143,7 @@ static void destroy_pid_namespace(struct pid_namespace *ns) | |||
142 | { | 143 | { |
143 | int i; | 144 | int i; |
144 | 145 | ||
145 | proc_free_inum(ns->proc_inum); | 146 | ns_free_inum(&ns->ns); |
146 | for (i = 0; i < PIDMAP_ENTRIES; i++) | 147 | for (i = 0; i < PIDMAP_ENTRIES; i++) |
147 | kfree(ns->pidmap[i].page); | 148 | kfree(ns->pidmap[i].page); |
148 | put_user_ns(ns->user_ns); | 149 | put_user_ns(ns->user_ns); |
@@ -333,7 +334,12 @@ int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd) | |||
333 | return 0; | 334 | return 0; |
334 | } | 335 | } |
335 | 336 | ||
336 | static void *pidns_get(struct task_struct *task) | 337 | static inline struct pid_namespace *to_pid_ns(struct ns_common *ns) |
338 | { | ||
339 | return container_of(ns, struct pid_namespace, ns); | ||
340 | } | ||
341 | |||
342 | static struct ns_common *pidns_get(struct task_struct *task) | ||
337 | { | 343 | { |
338 | struct pid_namespace *ns; | 344 | struct pid_namespace *ns; |
339 | 345 | ||
@@ -343,18 +349,18 @@ static void *pidns_get(struct task_struct *task) | |||
343 | get_pid_ns(ns); | 349 | get_pid_ns(ns); |
344 | rcu_read_unlock(); | 350 | rcu_read_unlock(); |
345 | 351 | ||
346 | return ns; | 352 | return ns ? &ns->ns : NULL; |
347 | } | 353 | } |
348 | 354 | ||
349 | static void pidns_put(void *ns) | 355 | static void pidns_put(struct ns_common *ns) |
350 | { | 356 | { |
351 | put_pid_ns(ns); | 357 | put_pid_ns(to_pid_ns(ns)); |
352 | } | 358 | } |
353 | 359 | ||
354 | static int pidns_install(struct nsproxy *nsproxy, void *ns) | 360 | static int pidns_install(struct nsproxy *nsproxy, struct ns_common *ns) |
355 | { | 361 | { |
356 | struct pid_namespace *active = task_active_pid_ns(current); | 362 | struct pid_namespace *active = task_active_pid_ns(current); |
357 | struct pid_namespace *ancestor, *new = ns; | 363 | struct pid_namespace *ancestor, *new = to_pid_ns(ns); |
358 | 364 | ||
359 | if (!ns_capable(new->user_ns, CAP_SYS_ADMIN) || | 365 | if (!ns_capable(new->user_ns, CAP_SYS_ADMIN) || |
360 | !ns_capable(current_user_ns(), CAP_SYS_ADMIN)) | 366 | !ns_capable(current_user_ns(), CAP_SYS_ADMIN)) |
@@ -382,19 +388,12 @@ static int pidns_install(struct nsproxy *nsproxy, void *ns) | |||
382 | return 0; | 388 | return 0; |
383 | } | 389 | } |
384 | 390 | ||
385 | static unsigned int pidns_inum(void *ns) | ||
386 | { | ||
387 | struct pid_namespace *pid_ns = ns; | ||
388 | return pid_ns->proc_inum; | ||
389 | } | ||
390 | |||
391 | const struct proc_ns_operations pidns_operations = { | 391 | const struct proc_ns_operations pidns_operations = { |
392 | .name = "pid", | 392 | .name = "pid", |
393 | .type = CLONE_NEWPID, | 393 | .type = CLONE_NEWPID, |
394 | .get = pidns_get, | 394 | .get = pidns_get, |
395 | .put = pidns_put, | 395 | .put = pidns_put, |
396 | .install = pidns_install, | 396 | .install = pidns_install, |
397 | .inum = pidns_inum, | ||
398 | }; | 397 | }; |
399 | 398 | ||
400 | static __init int pid_namespaces_init(void) | 399 | static __init int pid_namespaces_init(void) |