lkml.org 
[lkml]   [2015]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] kprobes/x86: Check for invalid ftrace location in __recover_probed_insn()
Date
__recover_probed_insn() should always be called from an address where
an instructions starts. The check for ftrace_location() might help to
discover a potential inconsistency. Something goes terribly wrong when
an address inside the ftrace location is checked. Let's BUG() in this case.

Suggested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Petr Mladek <pmladek@suse.cz>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
arch/x86/kernel/kprobes/core.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 2f464b56766a..124577dcf768 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -228,6 +228,12 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
kp = get_kprobe((void *)addr);
faddr = ftrace_location(addr);
/*
+ * Addresses inside the ftrace location are refused by
+ * arch_check_ftrace_location(). Something went terribly wrong
+ * if such an address is checked here.
+ */
+ BUG_ON(faddr && faddr != addr);
+ /*
* Use the current code if it is not modified by Kprobe
* and it cannot be modified by ftrace.
*/
--
1.8.5.6


\
 
 \ /
  Last update: 2015-02-20 11:41    [W:0.087 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site