[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20120904160442.GB8199@redhat.com>
Date: Tue, 4 Sep 2012 18:04:42 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Andrew Vagin <avagin@...nvz.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>, criu@...nvz.org,
linux-kernel@...r.kernel.org,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Pavel Emelyanov <xemul@...allels.com>
Subject: Re: [PATCH] kernel: limit a value of ns_last_pid to (0, max_pid)
On 09/04, Andrew Vagin wrote:
>
> The kernel doesn't check pid on a negative values, so if
> you would try to write -2 in /proc/sys/kernel/ns_last_pid,
> you will get a kernel panic.
>
> In this case the next pid is -1, and alloc_pidmap will try to access
> to a nonexistent pidmap.
>
> map = &pid_ns->pidmap[pid/BITS_PER_PAGE];
Yes, alloc_pidmap() assumes that pid_ns->last_pid + 1 is positive...
So ".extra1 = &zero" is not enough, INT_MAX can overflow as well.
> static struct ctl_table pid_ns_ctl_table[] = {
> {
> .procname = "ns_last_pid",
> .maxlen = sizeof(int),
> .mode = 0666, /* permissions are checked in the handler */
> .proc_handler = pid_ns_ctl_handler,
> + .extra1 = &zero,
> + .extra2 = &pid_max,
Acked-by: Oleg Nesterov <oleg@...hat.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists