mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Revert "kprobes: Warn if optprobe handler tries to change execution path"
@ 2017-10-17  8:18 Naveen N. Rao
  2017-10-18 16:22 ` [tip:perf/core] " tip-bot for Naveen N. Rao
  2017-10-19 21:38 ` [PATCH] " Masami Hiramatsu
  0 siblings, 2 replies; 4+ messages in thread
From: Naveen N. Rao @ 2017-10-17  8:18 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Masami Hiramatsu, Michael Ellerman, Ananth N Mavinakayanahalli,
	linux-kernel

This reverts commit e863d539614641 ("kprobes: Warn if optprobe handler
tries to change execution path").

On powerpc, we place a probe at kretprobe_trampoline to catch function
returns and with CONFIG_OPTPROBES, this probe gets optimized. This
works for us due to the way we handle the optprobe as described in
commit 762df10bad6954 ("powerpc/kprobes: Optimize kprobe
in kretprobe_trampoline()"). With the above commit, we end up with a
warning. As such, revert this change.

Reported-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
Discussion here:
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1510995.html

 kernel/kprobes.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 2d28377a0e32..15fba7fe57c8 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -387,10 +387,7 @@ void opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
 	list_for_each_entry_rcu(kp, &p->list, list) {
 		if (kp->pre_handler && likely(!kprobe_disabled(kp))) {
 			set_kprobe_instance(kp);
-			if (kp->pre_handler(kp, regs)) {
-				if (WARN_ON_ONCE(1))
-					pr_err("Optprobe ignores instruction pointer changing.(%pF)\n", p->addr);
-			}
+			kp->pre_handler(kp, regs);
 		}
 		reset_kprobe_instance();
 	}
-- 
2.14.2

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

* [tip:perf/core] Revert "kprobes: Warn if optprobe handler tries to change execution path"
  2017-10-17  8:18 [PATCH] Revert "kprobes: Warn if optprobe handler tries to change execution path" Naveen N. Rao
@ 2017-10-18 16:22 ` tip-bot for Naveen N. Rao
  2017-10-19 21:38 ` [PATCH] " Masami Hiramatsu
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Naveen N. Rao @ 2017-10-18 16:22 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: torvalds, mingo, peterz, hpa, mpe, tglx, mhiramat, linux-kernel,
	ananth, naveen.n.rao

Commit-ID:  4f3a871443669c6b4d458a60ac8d8ca5eedc3f97
Gitweb:     https://git.kernel.org/tip/4f3a871443669c6b4d458a60ac8d8ca5eedc3f97
Author:     Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
AuthorDate: Tue, 17 Oct 2017 13:48:34 +0530
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 18 Oct 2017 15:21:35 +0200

Revert "kprobes: Warn if optprobe handler tries to change execution path"

This reverts commit:

  e863d539614641 ("kprobes: Warn if optprobe handler tries to change execution path")

On PowerPC, we place a probe at kretprobe_trampoline to catch function
returns and with CONFIG_OPTPROBES=y, this probe gets optimized. This
works for us due to the way we handle the optprobe as described in
commit:

  762df10bad6954 ("powerpc/kprobes: Optimize kprobe in kretprobe_trampoline()")

With the above commit, we end up with a warning. As such, revert this change.

Reported-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20171017081834.3629-1-naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/kprobes.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 2d28377..15fba7f 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -387,10 +387,7 @@ void opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
 	list_for_each_entry_rcu(kp, &p->list, list) {
 		if (kp->pre_handler && likely(!kprobe_disabled(kp))) {
 			set_kprobe_instance(kp);
-			if (kp->pre_handler(kp, regs)) {
-				if (WARN_ON_ONCE(1))
-					pr_err("Optprobe ignores instruction pointer changing.(%pF)\n", p->addr);
-			}
+			kp->pre_handler(kp, regs);
 		}
 		reset_kprobe_instance();
 	}

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

* Re: [PATCH] Revert "kprobes: Warn if optprobe handler tries to change execution path"
  2017-10-17  8:18 [PATCH] Revert "kprobes: Warn if optprobe handler tries to change execution path" Naveen N. Rao
  2017-10-18 16:22 ` [tip:perf/core] " tip-bot for Naveen N. Rao
@ 2017-10-19 21:38 ` Masami Hiramatsu
  2017-10-23 13:58   ` Naveen N. Rao
  1 sibling, 1 reply; 4+ messages in thread
From: Masami Hiramatsu @ 2017-10-19 21:38 UTC (permalink / raw)
  To: Naveen N. Rao
  Cc: Ingo Molnar, Masami Hiramatsu, Michael Ellerman,
	Ananth N Mavinakayanahalli, linux-kernel

On Tue, 17 Oct 2017 13:48:34 +0530
"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:

> This reverts commit e863d539614641 ("kprobes: Warn if optprobe handler
> tries to change execution path").
> 
> On powerpc, we place a probe at kretprobe_trampoline to catch function
> returns and with CONFIG_OPTPROBES, this probe gets optimized. This
> works for us due to the way we handle the optprobe as described in
> commit 762df10bad6954 ("powerpc/kprobes: Optimize kprobe
> in kretprobe_trampoline()"). With the above commit, we end up with a
> warning. As such, revert this change.

OK, so for ppc, optprobe can handle nip change.

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

I'll update the document too.

Thanks,

> 
> Reported-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> ---
> Discussion here:
> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1510995.html
> 
>  kernel/kprobes.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 2d28377a0e32..15fba7fe57c8 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -387,10 +387,7 @@ void opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
>  	list_for_each_entry_rcu(kp, &p->list, list) {
>  		if (kp->pre_handler && likely(!kprobe_disabled(kp))) {
>  			set_kprobe_instance(kp);
> -			if (kp->pre_handler(kp, regs)) {
> -				if (WARN_ON_ONCE(1))
> -					pr_err("Optprobe ignores instruction pointer changing.(%pF)\n", p->addr);
> -			}
> +			kp->pre_handler(kp, regs);
>  		}
>  		reset_kprobe_instance();
>  	}
> -- 
> 2.14.2
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* Re: [PATCH] Revert "kprobes: Warn if optprobe handler tries to change execution path"
  2017-10-19 21:38 ` [PATCH] " Masami Hiramatsu
@ 2017-10-23 13:58   ` Naveen N. Rao
  0 siblings, 0 replies; 4+ messages in thread
From: Naveen N. Rao @ 2017-10-23 13:58 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Ingo Molnar, Michael Ellerman, Ananth N Mavinakayanahalli, linux-kernel

On 2017/10/19 09:38PM, Masami Hiramatsu wrote:
> On Tue, 17 Oct 2017 13:48:34 +0530
> "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:
> 
> > This reverts commit e863d539614641 ("kprobes: Warn if optprobe handler
> > tries to change execution path").
> > 
> > On powerpc, we place a probe at kretprobe_trampoline to catch function
> > returns and with CONFIG_OPTPROBES, this probe gets optimized. This
> > works for us due to the way we handle the optprobe as described in
> > commit 762df10bad6954 ("powerpc/kprobes: Optimize kprobe
> > in kretprobe_trampoline()"). With the above commit, we end up with a
> > warning. As such, revert this change.
> 
> OK, so for ppc, optprobe can handle nip change.
> 
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
> 
> I'll update the document too.

Thanks. We don't quite handle the nip change (yet), but just work around 
it for kretprobe trampoline by using the link register, and issuing a 
'blr' after the trampoline code.

Regards,
Naveen

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

end of thread, other threads:[~2017-10-23 13:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-17  8:18 [PATCH] Revert "kprobes: Warn if optprobe handler tries to change execution path" Naveen N. Rao
2017-10-18 16:22 ` [tip:perf/core] " tip-bot for Naveen N. Rao
2017-10-19 21:38 ` [PATCH] " Masami Hiramatsu
2017-10-23 13:58   ` Naveen N. Rao

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