[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20070530083939.GA10627@localhost.sw.ru>
Date: Wed, 30 May 2007 12:39:39 +0400
From: Alexey Dobriyan <adobriyan@...ru>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, devel@...nvz.org
Subject: Re: [PATCH] /proc/*/environ: wrong placing of ptrace_may_attach() check
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@...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.
-
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