Re: [PATCH v2 2.6.38-rc8-tip 7/20] 7: uprobes: store/restoreoriginal instruction.

From: Balbir Singh
Date: Tue Mar 15 2011 - 14:58:55 EST


* Peter Zijlstra <peterz@xxxxxxxxxxxxx> [2011-03-15 18:57:42]:

> On Tue, 2011-03-15 at 14:52 +0530, Srikar Dronamraju wrote:
> > * Stephen Wilson <wilsons@xxxxxxxx> [2011-03-14 14:09:14]:
> >
> > > On Mon, Mar 14, 2011 at 07:05:22PM +0530, Srikar Dronamraju wrote:
> > > > static int install_uprobe(struct mm_struct *mm, struct uprobe *uprobe)
> > > > {
> > > > - int ret = 0;
> > > > + struct task_struct *tsk;
> > > > + int ret = -EINVAL;
> > > >
> > > > - /*TODO: install breakpoint */
> > > > - if (!ret)
> > > > + get_task_struct(mm->owner);
> > > > + tsk = mm->owner;
> > > > + if (!tsk)
> > > > + return ret;
> > >
> > > I think you need to check that tsk != NULL before calling
> > > get_task_struct()...
> > >
> >
> > Guess checking for tsk != NULL would only help if and only if we are doing
> > within rcu. i.e we have to change to something like this
> >
> > rcu_read_lock()
> > if (mm->owner) {
> > get_task_struct(mm->owner)
> > tsk = mm->owner;
> > }
> > rcu_read_unlock()
> > if (!tsk)
> > return ret;
>
> so the whole mm->owner semantics seem vague, memcontrol.c doesn't seem
> consistent in itself, one site uses rcu_dereference() the other site
> doesn't.
>

mm->owner should be under rcu_read_lock, unless the task is exiting
and mm_count is 1. mm->owner is updated under task_lock().

> Also, the assignments in kernel/fork.c and kernel/exit.c don't use
> rcu_assign_pointer() and therefore lack the needed write barrier.
>

Those are paths when the only context using the mm->owner is single

> Git blames Balbir for this.

I accept the blame and am willing to fix anything incorrect found in
the code.


--
Three Cheers,
Balbir
--
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/