From: Oleg Nesterov <oleg@redhat.com>
To: Djalal Harouni <tixxdz@opendz.org>
Cc: linux-kernel@vger.kernel.org,
kernel-hardening@lists.openwall.com,
Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Vasiliy Kulikov <segoon@openwall.com>,
WANG Cong <xiyou.wangcong@gmail.com>,
Solar Designer <solar@openwall.com>,
Kees Cook <keescook@chromium.org>
Subject: Re: [PATCH] proc: do not allow negative offsets on /proc/<pid>/environ
Date: Sun, 22 Jul 2012 22:00:49 +0200 [thread overview]
Message-ID: <20120722200049.GA29222@redhat.com> (raw)
In-Reply-To: <1342974959-2748-1-git-send-email-tixxdz@opendz.org>
On 07/22, Djalal Harouni wrote:
>
> __mem_open() which is called by both /proc/<pid>/environ and
> /proc/<pid>/mem ->open() handlers will allow the use of negative offsets.
> /proc/<pid>/mem has negative offsets but not /proc/<pid>/environ.
Probablt the patch makes sense, but I can't understand the changelog...
> Allowing negative offsets on /proc/<pid>/environ can turn it to act like
> /proc/<pid>/mem. A negative offset will pass the
> fs/read_write.c:lseek_execute() and the environ_read() checks and will
> point to another VMA.
which VMA?
environ_read() can only read the memory from [env_start, env_end], and
it should check *ppos anyway to ensure it doesn't read something else.
> static int mem_open(struct inode *inode, struct file *file)
> {
> - return __mem_open(inode, file, PTRACE_MODE_ATTACH);
> + int ret = __mem_open(inode, file, PTRACE_MODE_ATTACH);
> + if (!ret)
> + /* OK to pass negative loff_t, we can catch out-of-range */
> + file->f_mode |= FMODE_UNSIGNED_OFFSET;
> +
> + return ret;
I guess you can set FMODE_UNSIGNED_OFFSET unconditionally, it doesn't
matter if __mem_open() fails. But I won't insist.
Oleg.
next prev parent reply other threads:[~2012-07-22 20:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-22 16:35 [PATCH] proc: do not allow negative offsets on /proc/<pid>/environ Djalal Harouni
2012-07-22 20:00 ` Oleg Nesterov [this message]
2012-07-23 1:04 ` Djalal Harouni
2012-07-23 15:49 ` Oleg Nesterov
2012-07-23 16:44 ` Djalal Harouni
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=20120722200049.GA29222@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=segoon@openwall.com \
--cc=solar@openwall.com \
--cc=tixxdz@opendz.org \
--cc=viro@zeniv.linux.org.uk \
--cc=xiyou.wangcong@gmail.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