linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -tip ] [BUGFIX] kprobes: Fix arch_prepare_kprobe to handle copy insn failures
@ 2013-06-05  3:12 Masami Hiramatsu
  2013-06-06 21:06 ` Steven Rostedt
  2013-06-20 14:48 ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
  0 siblings, 2 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2013-06-05  3:12 UTC (permalink / raw)
  To: Ingo Molnar, linux-kernel
  Cc: Ingo Molnar, Frank Ch. Eigler, Steven Rostedt, systemtap,
	yrl.pp-manager.tt

Fix arch_prepare_kprobe() to handle failures in copy instruction
correctly. This fix is related to the previous fix: 8101376
which made __copy_instruction return an error result if failed,
but caller site was not updated to handle it. Thus, this is the
other half of the bugfix.

This fix is also 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: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/kprobes/core.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 9895a9a..211bce4 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -365,10 +365,14 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
 	return insn.length;
 }
 
-static void __kprobes arch_copy_kprobe(struct kprobe *p)
+static int __kprobes arch_copy_kprobe(struct kprobe *p)
 {
+	int ret;
+
 	/* Copy an instruction with recovering if other optprobe modifies it.*/
-	__copy_instruction(p->ainsn.insn, p->addr);
+	ret = __copy_instruction(p->ainsn.insn, p->addr);
+	if (!ret)
+		return -EINVAL;
 
 	/*
 	 * __copy_instruction can modify the displacement of the instruction,
@@ -384,6 +388,8 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
 
 	/* Also, displacement change doesn't affect the first byte */
 	p->opcode = p->ainsn.insn[0];
+
+	return 0;
 }
 
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
@@ -397,8 +403,8 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 	p->ainsn.insn = get_insn_slot();
 	if (!p->ainsn.insn)
 		return -ENOMEM;
-	arch_copy_kprobe(p);
-	return 0;
+
+	return arch_copy_kprobe(p);
 }
 
 void __kprobes arch_arm_kprobe(struct kprobe *p)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH -tip ] [BUGFIX] kprobes: Fix arch_prepare_kprobe to handle copy insn failures
  2013-06-05  3:12 [PATCH -tip ] [BUGFIX] kprobes: Fix arch_prepare_kprobe to handle copy insn failures Masami Hiramatsu
@ 2013-06-06 21:06 ` Steven Rostedt
  2013-06-07 21:18   ` Jonathan Lebon
  2013-06-20 14:48 ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
  1 sibling, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2013-06-06 21:06 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Ingo Molnar, linux-kernel, Ingo Molnar, Frank Ch. Eigler,
	systemtap, yrl.pp-manager.tt

On Wed, 2013-06-05 at 12:12 +0900, Masami Hiramatsu wrote:
> Fix arch_prepare_kprobe() to handle failures in copy instruction
> correctly. This fix is related to the previous fix: 8101376
> which made __copy_instruction return an error result if failed,
> but caller site was not updated to handle it. Thus, this is the
> other half of the bugfix.
> 
> This fix is also 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>

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

> Cc: Ingo Molnar <mingo@kernel.org>
> ---
>  arch/x86/kernel/kprobes/core.c |   14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -tip ] [BUGFIX] kprobes: Fix arch_prepare_kprobe to handle copy insn failures
  2013-06-06 21:06 ` Steven Rostedt
@ 2013-06-07 21:18   ` Jonathan Lebon
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Lebon @ 2013-06-07 21:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Masami Hiramatsu, Ingo Molnar, linux-kernel, Ingo Molnar,
	Frank Ch. Eigler, systemtap, yrl pp-manager tt

Tested-by: Jonathan Lebon <jlebon@redhat.com>

Stress-tested overnight in a VM with no problems.

Jonathan

----- Original Message -----
From: "Steven Rostedt" <rostedt@goodmis.org>
To: "Masami Hiramatsu" <masami.hiramatsu.pt@hitachi.com>
Cc: "Ingo Molnar" <mingo@redhat.com>, linux-kernel@vger.kernel.org, "Ingo Molnar" <mingo@kernel.org>, "Frank Ch. Eigler" <fche@redhat.com>, systemtap@sourceware.org, "yrl pp-manager tt" <yrl.pp-manager.tt@hitachi.com>
Sent: Thursday, June 6, 2013 5:06:46 PM
Subject: Re: [PATCH -tip ] [BUGFIX] kprobes: Fix arch_prepare_kprobe to handle copy insn failures

On Wed, 2013-06-05 at 12:12 +0900, Masami Hiramatsu wrote:
> Fix arch_prepare_kprobe() to handle failures in copy instruction
> correctly. This fix is related to the previous fix: 8101376
> which made __copy_instruction return an error result if failed,
> but caller site was not updated to handle it. Thus, this is the
> other half of the bugfix.
> 
> This fix is also 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>

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

> Cc: Ingo Molnar <mingo@kernel.org>
> ---
>  arch/x86/kernel/kprobes/core.c |   14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perf/urgent] kprobes: Fix arch_prepare_kprobe to handle copy insn failures
  2013-06-05  3:12 [PATCH -tip ] [BUGFIX] kprobes: Fix arch_prepare_kprobe to handle copy insn failures Masami Hiramatsu
  2013-06-06 21:06 ` Steven Rostedt
@ 2013-06-20 14:48 ` tip-bot for Masami Hiramatsu
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2013-06-20 14:48 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, fche, hpa, mingo, masami.hiramatsu.pt, rostedt,
	jlebon, tglx

Commit-ID:  003002e04ed38618fc37b92ba128f5ca79d39f4f
Gitweb:     http://git.kernel.org/tip/003002e04ed38618fc37b92ba128f5ca79d39f4f
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Wed, 5 Jun 2013 12:12:16 +0900
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 20 Jun 2013 14:25:48 +0200

kprobes: Fix arch_prepare_kprobe to handle copy insn failures

Fix arch_prepare_kprobe() to handle failures in copy instruction
correctly. This fix is related to the previous fix: 8101376
which made __copy_instruction return an error result if failed,
but caller site was not updated to handle it. Thus, this is the
other half of the bugfix.

This fix is also 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>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Tested-by: Jonathan Lebon <jlebon@redhat.com>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: systemtap@sourceware.org
Cc: yrl.pp-manager.tt@hitachi.com
Link: http://lkml.kernel.org/r/20130605031216.15285.2001.stgit@mhiramat-M0-7522
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/kprobes/core.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 9895a9a..211bce4 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -365,10 +365,14 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
 	return insn.length;
 }
 
-static void __kprobes arch_copy_kprobe(struct kprobe *p)
+static int __kprobes arch_copy_kprobe(struct kprobe *p)
 {
+	int ret;
+
 	/* Copy an instruction with recovering if other optprobe modifies it.*/
-	__copy_instruction(p->ainsn.insn, p->addr);
+	ret = __copy_instruction(p->ainsn.insn, p->addr);
+	if (!ret)
+		return -EINVAL;
 
 	/*
 	 * __copy_instruction can modify the displacement of the instruction,
@@ -384,6 +388,8 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
 
 	/* Also, displacement change doesn't affect the first byte */
 	p->opcode = p->ainsn.insn[0];
+
+	return 0;
 }
 
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
@@ -397,8 +403,8 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 	p->ainsn.insn = get_insn_slot();
 	if (!p->ainsn.insn)
 		return -ENOMEM;
-	arch_copy_kprobe(p);
-	return 0;
+
+	return arch_copy_kprobe(p);
 }
 
 void __kprobes arch_arm_kprobe(struct kprobe *p)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-20 14:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-05  3:12 [PATCH -tip ] [BUGFIX] kprobes: Fix arch_prepare_kprobe to handle copy insn failures Masami Hiramatsu
2013-06-06 21:06 ` Steven Rostedt
2013-06-07 21:18   ` Jonathan Lebon
2013-06-20 14:48 ` [tip:perf/urgent] " 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;
as well as URLs for NNTP newsgroup(s).