From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Vagin <avagin@openvz.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
criu@openvz.org, linux-kernel@vger.kernel.org,
"Eric W. Biederman" <ebiederm@xmission.com>,
Pavel Emelyanov <xemul@parallels.com>
Subject: Re: [PATCH] kernel: limit a value of ns_last_pid to (0, max_pid)
Date: Tue, 4 Sep 2012 18:04:42 +0200 [thread overview]
Message-ID: <20120904160442.GB8199@redhat.com> (raw)
In-Reply-To: <1346746632-3025128-1-git-send-email-avagin@openvz.org>
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@redhat.com>
prev parent reply other threads:[~2012-09-04 16:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-04 8:17 [PATCH] kernel: limit a value of ns_last_pid to (0, max_pid) Andrew Vagin
2012-09-04 16:04 ` Oleg Nesterov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120904160442.GB8199@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@openvz.org \
--cc=criu@openvz.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=xemul@parallels.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).