[lkml]   [2009]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [RFC PATCH 3/3a] ptrace: add _ptrace_may_access()
> I was going to cleanup this later. Because I think that
> __ptrace_may_access() should die. It has only one caller, mm_for_maps().

CC'ing Al Viro, who wrote mm_for_maps() (and no one has touched it since,
see commit 831830b).

> 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;
> }

That seems fine to me. I suspect the old code just predated the PF_KTHREAD
check in get_task_mm() and excluding the borrowed-mm window races was the
only reason for using task_lock() that way.

> ? 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.

I agree.


 \ /
  Last update: 2009-05-07 02:25    [W:0.069 / U:19.592 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site