mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
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 <[email protected]> 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" <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
This commit is contained in:
parent
17cf22c33e
commit
0a01f2cc39
6 changed files with 26 additions and 22 deletions
|
|
@ -2590,10 +2590,6 @@ void proc_flush_task(struct task_struct *task)
|
|||
proc_flush_task_mnt(upid->ns->proc_mnt, upid->nr,
|
||||
tgid->numbers[i].nr);
|
||||
}
|
||||
|
||||
upid = &pid->numbers[pid->level];
|
||||
if (upid->nr == 1)
|
||||
pid_ns_release_proc(upid->ns);
|
||||
}
|
||||
|
||||
static struct dentry *proc_pid_instantiate(struct inode *dir,
|
||||
|
|
|
|||
|
|
@ -155,11 +155,6 @@ void __init proc_root_init(void)
|
|||
err = register_filesystem(&proc_fs_type);
|
||||
if (err)
|
||||
return;
|
||||
err = pid_ns_prepare_proc(&init_pid_ns);
|
||||
if (err) {
|
||||
unregister_filesystem(&proc_fs_type);
|
||||
return;
|
||||
}
|
||||
|
||||
proc_self_init();
|
||||
proc_symlink("mounts", NULL, "self/mounts");
|
||||
|
|
|
|||
Loading…
Reference in a new issue