Re: [RFC PATCH v4 4/6] uretprobes: return probe entry, prepare uretprobe

Anton Arapov
2013-03-05T13:21:11Z

On Mon, Mar 04, 2013 at 05:47:53PM +0100, Oleg Nesterov wrote:
> On 03/04, Anton Arapov wrote:
> >
> > @@ -1085,6 +1093,7 @@ static int xol_add_vma(struct xol_area *area)
> > {
> > struct mm_struct *mm = current->mm;
> > int ret = -EALREADY;
> > + uprobe_opcode_t insn = UPROBE_SWBP_INSN;
> >
> > down_write(&mm->mmap_sem);
> > if (mm->uprobes_state.xol_area)
> > @@ -1106,6 +1115,13 @@ static int xol_add_vma(struct xol_area *area)
> > smp_wmb(); /* pairs with get_xol_area() */
> > mm->uprobes_state.xol_area = area;
> > ret = 0;
> > +
> > + /*
> > + * If we reached this place, we did allocate a new area. We want
> > + * pre-alloc a slot for the return probes here.
> > + */
> > + xol_get_insn_slot(&insn);
> Just change get_xol_area() to do set_bit(0, bitmap) and copy_to_page(page, int3)
> (extacted from xol_get_insn_slot().
ah yes, right. Thanks for this hint.

>
> > @@ -1485,8 +1538,11 @@ static struct uprobe *find_active_uprobe(unsigned long bp_vaddr, int *is_swbp)
> > *is_swbp = -EFAULT;
> > }
> >
> > - if (!uprobe && test_and_clear_bit(MMF_RECALC_UPROBES, &mm->flags))
> > + utask = get_utask();
> > + if (!uprobe && hlist_empty(&utask->return_uprobes) &&
> > + test_and_clear_bit(MMF_RECALC_UPROBES, &mm->flags)) {
> > mmf_recalc_uprobes(mm);
> Wait, I was wrong. We should not clear MMF_* if another thread has
> ->return_uprobes. Perhaps we should change uprobe_pre_sstep_notifier()
> instead...
Will look into it.

> > down_read(&uprobe->register_rwsem);
> > for (uc = uprobe->consumers; uc; uc = uc->next) {
> > - int rc = uc->handler(uc, regs);
> > + if (uc->handler)
> > + rc = uc->handler(uc, regs);
> > +
> > + if (uc->rp_handler)
> > + prepare_uretprobe(uprobe, regs); /* put bp at return */
> Again, this is not right. We should do this only once after the main
> loop.
fixed for v5.

Thanks!
Anton.