aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/events
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2012-05-29 15:29:47 -0400
committerIngo Molnar <mingo@kernel.org>2012-06-06 11:22:03 -0400
commit56bb4cf6475d702d2fb00fc641aa6441097c0330 (patch)
tree0be90e9cdb9d998e9ca795f12eb530b397435844 /kernel/events
parent77fc4af1b59d12ab3b1467adf0a5204806853123 (diff)
uprobes: Teach handle_swbp() to rely on "is_swbp" rather than uprobes_srcu
Currently handle_swbp() assumes that it can't race with unregister, so it roughly does: if (find_uprobe(vaddr)) process_uprobe(); else send_sig(SIGTRAP); This relies on the not-really-working uprobes_srcu code we are going to remove, see the next patch. With this patch we rely on the result of is_swbp_at_addr(bp_vaddr) if find_uprobe() fails. If is_swbp == 1, then we hit the normal int3, we should send SIGTRAP. If is_swbp == 0, we raced with uprobe_unregister(), we simply restart this insn again. The "difficult" case is is_swbp == -EFAULT, when we can't read this memory. In this case I think we should restart too, and this is more correct compared to the current code which sends SIGTRAP. Ignoring ENOMEM/etc from get_user_pages(), this can only happen if another thread unmaps this memory before find_active_uprobe() takes mmap_sem. It would be better to pretend it was unmapped before this insn was executed, restart, and get SIGSEGV. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Anton Arapov <anton@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20120529192947.GF8057@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-rw-r--r--kernel/events/uprobes.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index a2ed82b4808c..1f02e3bbfc1d 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1530,14 +1530,26 @@ static void handle_swbp(struct pt_regs *regs)
1530 struct uprobe_task *utask; 1530 struct uprobe_task *utask;
1531 struct uprobe *uprobe; 1531 struct uprobe *uprobe;
1532 unsigned long bp_vaddr; 1532 unsigned long bp_vaddr;
1533 int is_swbp; 1533 int uninitialized_var(is_swbp);
1534 1534
1535 bp_vaddr = uprobe_get_swbp_addr(regs); 1535 bp_vaddr = uprobe_get_swbp_addr(regs);
1536 uprobe = find_active_uprobe(bp_vaddr, &is_swbp); 1536 uprobe = find_active_uprobe(bp_vaddr, &is_swbp);
1537 1537
1538 if (!uprobe) { 1538 if (!uprobe) {
1539 /* No matching uprobe; signal SIGTRAP. */ 1539 if (is_swbp > 0) {
1540 send_sig(SIGTRAP, current, 0); 1540 /* No matching uprobe; signal SIGTRAP. */
1541 send_sig(SIGTRAP, current, 0);
1542 } else {
1543 /*
1544 * Either we raced with uprobe_unregister() or we can't
1545 * access this memory. The latter is only possible if
1546 * another thread plays with our ->mm. In both cases
1547 * we can simply restart. If this vma was unmapped we
1548 * can pretend this insn was not executed yet and get
1549 * the (correct) SIGSEGV after restart.
1550 */
1551 instruction_pointer_set(regs, bp_vaddr);
1552 }
1541 return; 1553 return;
1542 } 1554 }
1543 1555