lkml.org 
[lkml]   [2017]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 3/3] kernel/uprobes: Fix check for active uprobe
Date
If we try to install a uprobe on a breakpoint instruction, we register the
probe, but refuse to install it. In this case, when the breakpoint hits, we
incorrectly assume that the probe hit and end up looping.

Fix this by checking that the trap was actually installed in
find_active_uprobe().

Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
kernel/events/uprobes.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index e14eb0a6e4f3..599078e6a092 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1752,6 +1752,13 @@ static struct uprobe *find_active_uprobe(unsigned long bp_vaddr, int *is_swbp)
uprobe = find_uprobe(inode, offset);
}

+ /* Ensure that the breakpoint was actually installed */
+ if (uprobe) {
+ smp_rmb(); /* pairs with wmb() in prepare_uprobe() */
+ if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags)))
+ uprobe = NULL;
+ }
+
if (!uprobe)
*is_swbp = is_trap_at_addr(mm, bp_vaddr);
} else {
--
2.14.1
\
 
 \ /
  Last update: 2017-09-13 22:31    [W:0.573 / U:0.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site