[lkml]   [2011]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH v7 3.2-rc2 4/30] uprobes: Define hooks for mmap/munmap.
    > int mmap_uprobe(...) {
    > ....
    > ret = install_breakpoint(vma->vm_mm, uprobe);
    > if (ret == -EEXIST) {
    > if (!read_opcode(vma->vm_mm, vaddr, &opcode) &&
    > (opcode == UPROBES_BKPT_INSN))
    > atomic_inc(&vma->vm_mm->mm_uprobes_count);
    > ret = 0;
    > }
    > ....
    > }

    Infact the check for EEXIST and read_opcode in mmap_uprobe() is needed
    for another reason too.

    Lets say while unregister_uprobe was around, a thread thats being
    probed, just forked a child and the child called mmap_uprobe.

    Now mmap_uprobe might find that the breakpoint is already inserted
    since the pages are shared with the parent. But before
    unregister_uprobe can come around and cleanup, the child can run and hit
    the breakpoint. Since the breakpoint count is 0 for the child, we dont
    expect the child to have hit a breakpoint placed by uprobes, and the
    child gets a SIGTRAP.

    With this check for read_opcode on EEXIST from install_breakpoint, we
    will know that there is a valid breakpoint underneath and increment
    the count. So on a breakpoint hit, the uprobes notifier does the right

    If the unregister_uprobe() had already cleanup the breakpoint in the
    parent, the child's copy would also be clean so read_opcode wont find
    the breakpoint and hence we wont increment the breakpoint.

    Thanks and Regards

     \ /
      Last update: 2011-11-30 06:35    [W:0.026 / U:1.636 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site