]> 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>
Thu, 18 Oct 2012 02:23:51 +0000 (13:23 +1100)
commita0c18bdb462b7a788e1d2e6da077ccfdb86fb44b
tree920a51cbcf48d799196c4a5a15358382409ea515
parent9dd5ec6e339df5e427c2227635abdbd4df6c9085
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