* [PATCH -tip ] kprobes/x86: Just return error for sanity check failure instead of using BUG_ON
@ 2013-04-04 10:42 Masami Hiramatsu
2013-04-10 9:22 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
0 siblings, 1 reply; 2+ messages in thread
From: Masami Hiramatsu @ 2013-04-04 10:42 UTC (permalink / raw)
To: Ingo Molnar, linux-kernel
Cc: Frank Ch. Eigler, H. Peter Anvin, Thomas Gleixner,
Steven Rostedt, yrl.pp-manager.tt
Return an error from __copy_instruction and use printk to
give us more productive message, since this is just an error
case which we can handle it and also the BUG_ON() never
tell us why and what happened,
This is related to the below bug-report.
https://bugzilla.redhat.com/show_bug.cgi?id=910649
Note, this patch is for help to analyze what happened.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
arch/x86/kernel/kprobes/core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 7bfe318..a86f83d 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)
* have given.
*/
newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
- BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
+ if ((s64) (s32) newdisp != newdisp) {
+ pr_err("Kprobes error: new displacement is not fit in s32 (%llx)\n", newdisp);
+ pr_err("\tSrc: %p, Dest: %p, old disp: %x\n", src, dest, insn.displacement.value);
+ return 0;
+ }
disp = (u8 *) dest + insn_offset_displacement(&insn);
*(s32 *) disp = (s32) newdisp;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [tip:perf/core] kprobes/x86: Just return error for sanity check failure instead of using BUG_ON
2013-04-04 10:42 [PATCH -tip ] kprobes/x86: Just return error for sanity check failure instead of using BUG_ON Masami Hiramatsu
@ 2013-04-10 9:22 ` tip-bot for Masami Hiramatsu
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2013-04-10 9:22 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, fche, hpa, mingo, masami.hiramatsu.pt, rostedt, tglx
Commit-ID: 8101376dc5f42bd93b36d4ab210b44503d0ec11f
Gitweb: http://git.kernel.org/tip/8101376dc5f42bd93b36d4ab210b44503d0ec11f
Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 4 Apr 2013 19:42:30 +0900
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 8 Apr 2013 17:28:34 +0200
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>
---
arch/x86/kernel/kprobes/core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 7bfe318..9895a9a 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)
* have given.
*/
newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
- BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
+ if ((s64) (s32) newdisp != newdisp) {
+ pr_err("Kprobes error: new displacement does not fit into s32 (%llx)\n", newdisp);
+ pr_err("\tSrc: %p, Dest: %p, old disp: %x\n", src, dest, insn.displacement.value);
+ return 0;
+ }
disp = (u8 *) dest + insn_offset_displacement(&insn);
*(s32 *) disp = (s32) newdisp;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-10 9:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-04 10:42 [PATCH -tip ] kprobes/x86: Just return error for sanity check failure instead of using BUG_ON Masami Hiramatsu
2013-04-10 9:22 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome