[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120802100515.GC5782@linux.vnet.ibm.com>
Date: Thu, 2 Aug 2012 15:35:15 +0530
From: Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Ingo Molnar <mingo@...e.hu>, Anton Arapov <anton@...hat.com>,
"Frank Ch. Eigler" <fche@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
William Cohen <wcohen@...hat.com>, linux-kernel@...r.kernel.org
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@...hat.com>
Signed-off-by: Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
Cc: Oleg Nesterov <oleg@...hat.com>
Cc: <stable@...r.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)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists