]> 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>
Fri, 7 Sep 2012 00:17:45 +0000 (10:17 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 7 Sep 2012 05:36:01 +0000 (15:36 +1000)
commitbaa44368cfb40cc8420bd316085610e7c4e2cb08
treef7b16bb462337c5adeab9af866c36947e8f3ca35
parent61fdb7ce52cc53a5d51e1f189767a411ae5c52c6
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