diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-08-01 13:33:47 -0400 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-11-19 08:59:10 -0500 |
commit | 0a01f2cc390e10633a54f72c608cc3fe19a50c3d (patch) | |
tree | e713a1c45b5ce125a5d33b61d528cd45264d47a7 /kernel/fork.c | |
parent | 17cf22c33e1f1b5e435469c84e43872579497653 (diff) |
pidns: Make the pidns proc mount/umount logic obvious.
Track the number of pids in the proc hash table. When the number of
pids goes to 0 schedule work to unmount the kernel mount of proc.
Move the mount of proc into alloc_pid when we allocate the pid for
init.
Remove the surprising calls of pid_ns_release proc in fork and
proc_flush_task. Those code paths really shouldn't know about proc
namespace implementation details and people have demonstrated several
times that finding and understanding those code paths is difficult and
non-obvious.
Because of the call path detach pid is alwasy called with the
rtnl_lock held free_pid is not allowed to sleep, so the work to
unmounting proc is moved to a work queue. This has the side benefit
of not blocking the entire world waiting for the unnecessary
rcu_barrier in deactivate_locked_super.
In the process of making the code clear and obvious this fixes a bug
reported by Gao feng <gaofeng@cn.fujitsu.com> where we would leak a
mount of proc during clone(CLONE_NEWPID|CLONE_NEWNET) if copy_pid_ns
succeeded and copy_net_ns failed.
Acked-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 7798c247f4b9..666dc8b06606 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1476,8 +1476,6 @@ bad_fork_cleanup_io: | |||
1476 | if (p->io_context) | 1476 | if (p->io_context) |
1477 | exit_io_context(p); | 1477 | exit_io_context(p); |
1478 | bad_fork_cleanup_namespaces: | 1478 | bad_fork_cleanup_namespaces: |
1479 | if (unlikely(clone_flags & CLONE_NEWPID)) | ||
1480 | pid_ns_release_proc(p->nsproxy->pid_ns); | ||
1481 | exit_task_namespaces(p); | 1479 | exit_task_namespaces(p); |
1482 | bad_fork_cleanup_mm: | 1480 | bad_fork_cleanup_mm: |
1483 | if (p->mm) | 1481 | if (p->mm) |