Re: [RFC PATCH 3/3a] ptrace: add _ptrace_may_access()
From: Oleg Nesterov
Date: Wed May 06 2009 - 20:00:01 EST
On 05/06, Ingo Molnar wrote:
>
> * Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
>
> > + task_lock(task);
> > retval = __ptrace_may_access(task, PTRACE_MODE_ATTACH);
> > + task_unlock(task);
> > if (retval)
> > - goto bad;
> > + goto unlock_creds;
>
> Hm, that's a bit ugly - why dont you reuse ptrace_may_access(),
> which does much of this already?
Indeed, even the changelog mentions this.
I was going to cleanup this later. Because I think that
__ptrace_may_access() should die. It has only one caller, mm_for_maps().
I will re-check, but it looks a bit strange. More precisely, I just
can't understand it. Why we can't just do
struct mm_struct *mm_for_maps(struct task_struct *task)
{
struct mm_struct *mm = get_task_mm(task);
if (mm && mm != current->mm && !ptrace_may_access()) {
mmput(mm);
mm = NULL;
}
return mm;
}
? We do not care if this task exits and clears ->mm right before
or after ptrace_may_access(), and this is possible eith the current
code too once it drops tasklist.
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/