Messages in this thread | | | Date | Thu, 17 Jul 2008 00:30:50 -0700 | From | Andrew Morton <> | Subject | Re: [PATCH 2/4] ptrace children revamp |
| |
On Thu, 17 Jul 2008 00:13:22 -0700 (PDT) Roland McGrath <roland@redhat.com> wrote:
> ptrace no longer fiddles with the children/sibling links, and the > old ptrace_children list is gone. Now ptrace, whether of one's own > children or another's via PTRACE_ATTACH, just uses the new ptraced > list instead. > > There should be no user-visible difference that matters. The only > change is the order in which do_wait() sees multiple stopped > children and stopped ptrace attachees. Since wait_task_stopped() > was changed earlier so it no longer reorders the children list, we > already know this won't cause any new problems. > > ... > > +repeat: > task_lock(current); > if (!(current->ptrace & PT_PTRACED)) { > + /* > + * See ptrace_attach() comments about the locking here. > + */
/* * Nasty, nasty. * * We want to hold both the task-lock and the * tasklist_lock for writing at the same time. * But that's against the rules (tasklist_lock * is taken for reading by interrupts on other * cpu's that may have task_lock). */
> + unsigned long flags; > + if (!write_trylock_irqsave(&tasklist_lock, flags)) { > + task_unlock(current); > + do { > + cpu_relax(); > + } while (!write_can_lock(&tasklist_lock)); > + goto repeat; > + } > +
hm, copying this code didn't do much to improve the world.
Is there any prospect of "fixing" this somehow?
Perhaps this code should be pulled up into a separate function, not that this will help things a lot.
> ret = security_ptrace(current->parent, current, > PTRACE_MODE_ATTACH); > + > /* > * Set the ptrace bit in the process ptrace flags. > + * Then link us on our parent's ptraced list. > */ > - if (!ret) > + if (!ret) { > current->ptrace |= PT_PTRACED; > + __ptrace_link(current, current->real_parent); > + } > + > + write_unlock_irqrestore(&tasklist_lock, flags); > } > task_unlock(current); > return ret;
| |