From: Alexey Dobriyan <adobriyan@sw.ru>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, devel@openvz.org
Subject: Re: [PATCH] /proc/*/environ: wrong placing of ptrace_may_attach() check
Date: Wed, 30 May 2007 12:39:39 +0400 [thread overview]
Message-ID: <20070530083939.GA10627@localhost.sw.ru> (raw)
In-Reply-To: <20070529171623.6879e159.akpm@linux-foundation.org>
On Tue, May 29, 2007 at 05:16:23PM -0700, Andrew Morton wrote:
> On Mon, 28 May 2007 17:41:57 +0400
> Alexey Dobriyan <adobriyan@sw.ru> wrote:
> > --- a/fs/proc/base.c
> > +++ b/fs/proc/base.c
> > @@ -204,12 +204,17 @@ static int proc_pid_environ(struct task_
> > int res = 0;
> > struct mm_struct *mm = get_task_mm(task);
> > if (mm) {
> > - unsigned int len = mm->env_end - mm->env_start;
> > + unsigned int len;
> > +
> > + res = -ESRCH;
> > + if (!ptrace_may_attach(task))
> > + goto out;
> > +
> > + len = mm->env_end - mm->env_start;
> > if (len > PAGE_SIZE)
> > len = PAGE_SIZE;
> > res = access_process_vm(task, mm->env_start, buffer, len, 0);
> > - if (!ptrace_may_attach(task))
> > - res = -ESRCH;
> > +out:
> > mmput(mm);
> > }
> > return res;
>
> What's wrong with the existing code? It's a bit dopey-looking and can, I
> guess, permit a task to cause a pagefault in an mm which it doesn't have
> permission to read from. But is there some more serious problem being
> fixed here?
I think not, because environment will be copied from target task, stay
in kernel tmp buffer, but not copied to target buffer due to -ESRCH.
But such code is asking for problems.
prev parent reply other threads:[~2007-05-30 8:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-28 13:41 [PATCH] /proc/*/environ: wrong placing of ptrace_may_attach() check Alexey Dobriyan
2007-05-30 0:16 ` Andrew Morton
2007-05-30 8:39 ` Alexey Dobriyan [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=20070530083939.GA10627@localhost.sw.ru \
--to=adobriyan@sw.ru \
--cc=akpm@linux-foundation.org \
--cc=devel@openvz.org \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.