• Cyrill Gorcunov's avatar
    pidns: remove recursion from free_pid_ns() · bbc2e3ef
    Cyrill Gorcunov authored
    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.
    
    [akpm@linux-foundation.org: export put_pid_ns() to modules]
    Signed-off-by: default avatarCyrill 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: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    bbc2e3ef
pid_namespace.c 6.9 KB