aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>2013-04-04 06:42:30 -0400
committerIngo Molnar <mingo@kernel.org>2013-04-08 11:28:34 -0400
commit8101376dc5f42bd93b36d4ab210b44503d0ec11f (patch)
tree7adb1e6a9ab280da5ce3e4fdc4f1e6fc42a2b4db
parent324670b620ab1ed00ba160e435686bd2ae4a59ce (diff)
kprobes/x86: Just return error for sanity check failure instead of using BUG_ON
Return an error from __copy_instruction() and use printk() to give us a more productive message, since this is just an error case which we can handle and also the BUG_ON() never tells us why and what happened. This is related to the following bug-report: https://bugzilla.redhat.com/show_bug.cgi?id=910649 Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Frank Ch. Eigler <fche@redhat.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: yrl.pp-manager.tt@hitachi.com Link: http://lkml.kernel.org/r/20130404104230.22862.85242.stgit@mhiramat-M0-7522 Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/kernel/kprobes/core.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 7bfe318d3d8a..9895a9a41380 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -353,7 +353,11 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
353 * have given. 353 * have given.
354 */ 354 */
355 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest; 355 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
356 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */ 356 if ((s64) (s32) newdisp != newdisp) {
357 pr_err("Kprobes error: new displacement does not fit into s32 (%llx)\n", newdisp);
358 pr_err("\tSrc: %p, Dest: %p, old disp: %x\n", src, dest, insn.displacement.value);
359 return 0;
360 }
357 disp = (u8 *) dest + insn_offset_displacement(&insn); 361 disp = (u8 *) dest + insn_offset_displacement(&insn);
358 *(s32 *) disp = (s32) newdisp; 362 *(s32 *) disp = (s32) newdisp;
359 } 363 }