]> git.karo-electronics.de Git - karo-tx-linux.git/commit
pid-namespace: limit value of ns_last_pid to (0, max_pid)
authorAndrew Vagin <avagin@openvz.org>
Thu, 13 Sep 2012 00:58:11 +0000 (10:58 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 17 Sep 2012 10:22:18 +0000 (20:22 +1000)
commit2fa9f1f0a30867e04c55320d9920f46229f5a105
treeaac35847be5069e760332fdaa4625add16b2b1e2
parent22cd718597ce834ff2631a337dafb64cf2e5cc8a
pid-namespace: limit value of ns_last_pid to (0, max_pid)

The kernel doesn't check the pid for negative values, so if you try to
write -2 to /proc/sys/kernel/ns_last_pid, you will get a kernel panic.

The crash happens because the next pid is -1, and alloc_pidmap() will try
to access to a nonexistent pidmap.

map = &pid_ns->pidmap[pid/BITS_PER_PAGE];

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