https://github.com/torvalds/linux
Revision bbc2e3ef87851bc5430b2b4cf4ca3a2f29baeda6 authored by Cyrill Gorcunov on 19 October 2012, 20:56:53 UTC, committed by Linus Torvalds on 19 October 2012, 21:07:47 UTC
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: 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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent dc36d7e
History
Tip revision: bbc2e3ef87851bc5430b2b4cf4ca3a2f29baeda6 authored by Cyrill Gorcunov on 19 October 2012, 20:56:53 UTC
pidns: remove recursion from free_pid_ns()
Tip revision: bbc2e3e
File Mode Size
isapnp
pnpacpi
pnpbios
Kconfig -rw-r--r-- 1.3 KB
Makefile -rw-r--r-- 331 bytes
base.h -rw-r--r-- 5.7 KB
card.c -rw-r--r-- 10.0 KB
core.c -rw-r--r-- 4.8 KB
driver.c -rw-r--r-- 5.4 KB
interface.c -rw-r--r-- 10.1 KB
manager.c -rw-r--r-- 9.3 KB
quirks.c -rw-r--r-- 10.1 KB
resource.c -rw-r--r-- 16.3 KB
support.c -rw-r--r-- 4.8 KB
system.c -rw-r--r-- 2.7 KB

back to top