Re: [PATCH v7 3.2-rc2 4/30] uprobes: Define hooks for mmap/munmap.

From: Srikar Dronamraju
Date: Wed Nov 30 2011 - 00:52:57 EST


>
> There's more cases, I forgot the details of how the prio_tree stuff
> works, so please consider if its possible to also have:
>
> __unregister_uprobe() will observe neither old nor new
>
> This could happen if we first munmap, __unregister_uprobe() will iterate
> past where mmap() will insert the new vma, mmap will insert the new vma,
> and __unregister_uprobe() will now not observe it.
>

- When we iterate thro __unregister_uprobe(), we always walk from the
root of the prio tree and not depend on the last found node. So
__unregister_uprobe able to iterate thro the rmap without finding the
old or the new vma would mean that the exclusive mmap_sem was dropped
for atleast a brief period and munmap/mmap are disjoint.

Here munmap_uprobe would have reduced the count followed by the pages
being cleared.
__unregister_uprobe maintains the status quo.
mmap_uprobe would load a new set of pages without any breakpoint, since
there are no consumers, and no underlying breakpoints, it also maintains
the status quo.

> and
>
> __unregister_uprobe() will observe both old _and_ new
>
> This latter could happen by favourably interleaving the prio_tree
> iteration with the munmap and mmap operations, so that we first observe
> the old vma, do the munmap, do the mmap, and then have the
> find_next_vma_info() thing find the new vma.

If __unregister_uprobe() can observe both old _and_ new, then it means
mmap has occurred. So its correct that probes are removed from
the old and new. The munmap_uprobe of the old vma wouldnt see the
breakpoint (via read_opcode) so wont decrement the count. If the
munmap_uprobe had seen the breakpoint before unregister_uprobe, then
unregister_uprobe cant decrement the count.

--
Thanks and Regards
Srikar

--
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/