From: Mike Galbraith Date: Thu, 10 May 2012 20:01:45 +0000 (-0700) Subject: namespaces, pid_ns: fix leakage on fork() failure X-Git-Tag: firefly_0821_release~7541^2~1200 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6f6f21eceec3a60d2066bb3b5e31dc14f9168fa7;p=firefly-linux-kernel-4.4.55.git namespaces, pid_ns: fix leakage on fork() failure commit 5e2bf0142231194d36fdc9596b36a261ed2b9fe7 upstream. Fork() failure post namespace creation for a child cloned with CLONE_NEWPID leaks pid_namespace/mnt_cache due to proc being mounted during creation, but not unmounted during cleanup. Call pid_ns_release_proc() during cleanup. Signed-off-by: Mike Galbraith Acked-by: Oleg Nesterov Reviewed-by: "Eric W. Biederman" Cc: Pavel Emelyanov Cc: Cyrill Gorcunov Cc: Louis Rilling Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/fork.c b/kernel/fork.c index a4e453b14f70..4712e3e5578e 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -1378,6 +1379,8 @@ bad_fork_cleanup_io: if (p->io_context) exit_io_context(p); bad_fork_cleanup_namespaces: + if (unlikely(clone_flags & CLONE_NEWPID)) + pid_ns_release_proc(p->nsproxy->pid_ns); exit_task_namespaces(p); bad_fork_cleanup_mm: if (p->mm) {