]> git.karo-electronics.de Git - karo-tx-linux.git/commit
pidns: remove recursion from free_pid_ns()
authorCyrill Gorcunov <gorcunov@openvz.org>
Fri, 12 Oct 2012 04:22:44 +0000 (15:22 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 15 Oct 2012 01:21:57 +0000 (12:21 +1100)
commit234a9f3c4ee1e35a4c1b4b6af7a85651ddea453b
tree5f527f9d6bd3b7957bc77d179f372fa2563dcaf0
parent737b55268c6548cb2d80ddba727818bc8928699d
pidns: remove recursion from free_pid_ns()

free_pid_ns() operates in a recursive fashion:

free_pid_ns(parent)
  put_pid_ns(parent)
    kref_put(&ns->kref, free_pid_ns);
      free_pid_ns

thus if there was a huge nesting of namespaces the userspace may trigger
avalanche calling of free_pid_ns leading to kernel stack exhausting and a
panic eventually.

This patch turns the recursion into an iterative loop.

Based on a patch by Andrew Vagin.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Andrew Vagin <avagin@openvz.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/pid_namespace.h
kernel/pid_namespace.c