lkml.org 
[lkml]   [2012]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH] uprobes: Ignore unsupported instructions in uprobe_mmap
    uprobe_mmap()->install_breakpoint() can fail if the probed insn is not
    supported (remember, uprobe_register() succeeds if nobody mmaps
    inode/offset). Failure in uprobe_mmap() causes mmap_region/do_fork to
    fail too.

    However failing mmap_region()/do_fork() because of a probe on an
    unsupported instruction is wrong.

    Hence change uprobe_mmap() to ignore unsupported instructions.

    Oleg Nesterov analyzed the root cause of this problem.

    While at it, add a missing put_uprobe() in the path where uprobe_mmap()
    races with uprobe_unregister().

    Reported-by: William Cohen <wcohen@redhat.com>
    Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: <stable@vger.kernel.org> # v3.5
    ---
    kernel/events/uprobes.c | 13 ++++++++++++-
    1 files changed, 12 insertions(+), 1 deletions(-)

    diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
    index c08a22d..c8a8c39 100644
    --- a/kernel/events/uprobes.c
    +++ b/kernel/events/uprobes.c
    @@ -1051,8 +1051,10 @@ int uprobe_mmap(struct vm_area_struct *vma)
    if (ret == -EEXIST) {
    ret = 0;

    - if (!is_swbp_at_addr(vma->vm_mm, vaddr))
    + if (!is_swbp_at_addr(vma->vm_mm, vaddr)) {
    + put_uprobe(uprobe);
    continue;
    + }

    /*
    * Unable to insert a breakpoint, but
    @@ -1060,6 +1062,15 @@ int uprobe_mmap(struct vm_area_struct *vma)
    * probe count.
    */
    atomic_inc(&vma->vm_mm->uprobes_state.count);
    + } else if (ret == -ENOTSUPP) {
    + /*
    + * A probe at unsupported instruction
    + * shouldnt cause mmap_region() / do_fork()
    + * to fail.
    + */
    + ret = 0;
    + put_uprobe(uprobe);
    + continue;
    }

    if (!ret)


    \
     
     \ /
      Last update: 2012-08-02 12:41    [W:0.056 / U:90.612 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site