linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] trace: reenable preemption if we modify the ip
@ 2017-12-16  2:42 Josef Bacik
  2017-12-17 19:49 ` Daniel Borkmann
  2017-12-18  7:29 ` Masami Hiramatsu
  0 siblings, 2 replies; 3+ messages in thread
From: Josef Bacik @ 2017-12-16  2:42 UTC (permalink / raw)
  To: netdev, mhiramat, ast, daniel, darrick.wong, linux-kernel; +Cc: Josef Bacik

From: Josef Bacik <jbacik@fb.com>

Things got moved around between the original bpf_override_return patches
and the final version, and now the ftrace kprobe dispatcher assumes if
you modified the ip that you also enabled preemption.  Make a comment of
this and enable preemption, this fixes the lockdep splat that happened
when using this feature.

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 kernel/trace/trace_kprobe.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 5db849809a56..91f4b57dab82 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1322,8 +1322,15 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs)
 	if (tk->tp.flags & TP_FLAG_TRACE)
 		kprobe_trace_func(tk, regs);
 #ifdef CONFIG_PERF_EVENTS
-	if (tk->tp.flags & TP_FLAG_PROFILE)
+	if (tk->tp.flags & TP_FLAG_PROFILE) {
 		ret = kprobe_perf_func(tk, regs);
+		/*
+		 * The ftrace kprobe handler leaves it up to us to re-enable
+		 * preemption here before returning if we've modified the ip.
+		 */
+		if (ret)
+			preempt_enable_no_resched();
+	}
 #endif
 	return ret;
 }
-- 
2.7.5

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

* Re: [PATCH] trace: reenable preemption if we modify the ip
  2017-12-16  2:42 [PATCH] trace: reenable preemption if we modify the ip Josef Bacik
@ 2017-12-17 19:49 ` Daniel Borkmann
  2017-12-18  7:29 ` Masami Hiramatsu
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2017-12-17 19:49 UTC (permalink / raw)
  To: Josef Bacik, netdev, mhiramat, ast, darrick.wong, linux-kernel
  Cc: Josef Bacik

On 12/16/2017 03:42 AM, Josef Bacik wrote:
> From: Josef Bacik <jbacik@fb.com>
> 
> Things got moved around between the original bpf_override_return patches
> and the final version, and now the ftrace kprobe dispatcher assumes if
> you modified the ip that you also enabled preemption.  Make a comment of
> this and enable preemption, this fixes the lockdep splat that happened
> when using this feature.
> 
> Signed-off-by: Josef Bacik <jbacik@fb.com>

Applied to bpf-next with Fixes tag, thanks Josef.

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

* Re: [PATCH] trace: reenable preemption if we modify the ip
  2017-12-16  2:42 [PATCH] trace: reenable preemption if we modify the ip Josef Bacik
  2017-12-17 19:49 ` Daniel Borkmann
@ 2017-12-18  7:29 ` Masami Hiramatsu
  1 sibling, 0 replies; 3+ messages in thread
From: Masami Hiramatsu @ 2017-12-18  7:29 UTC (permalink / raw)
  To: Josef Bacik; +Cc: netdev, ast, daniel, darrick.wong, linux-kernel, Josef Bacik

On Fri, 15 Dec 2017 21:42:57 -0500
Josef Bacik <josef@toxicpanda.com> wrote:

> From: Josef Bacik <jbacik@fb.com>
> 
> Things got moved around between the original bpf_override_return patches
> and the final version, and now the ftrace kprobe dispatcher assumes if
> you modified the ip that you also enabled preemption.  Make a comment of
> this and enable preemption, this fixes the lockdep splat that happened
> when using this feature.
> 
> Signed-off-by: Josef Bacik <jbacik@fb.com>
> ---
>  kernel/trace/trace_kprobe.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index 5db849809a56..91f4b57dab82 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -1322,8 +1322,15 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs)
>  	if (tk->tp.flags & TP_FLAG_TRACE)
>  		kprobe_trace_func(tk, regs);
>  #ifdef CONFIG_PERF_EVENTS
> -	if (tk->tp.flags & TP_FLAG_PROFILE)
> +	if (tk->tp.flags & TP_FLAG_PROFILE) {
>  		ret = kprobe_perf_func(tk, regs);
> +		/*
> +		 * The ftrace kprobe handler leaves it up to us to re-enable
> +		 * preemption here before returning if we've modified the ip.
> +		 */
> +		if (ret)
> +			preempt_enable_no_resched();

Where is reset_current_kprobe()?
Since kprobes still expects this modification is used by jprobes,
we need to call it in caller-side.

Thank you,

> +	}
>  #endif
>  	return ret;
>  }
> -- 
> 2.7.5
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

end of thread, other threads:[~2017-12-18  7:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-16  2:42 [PATCH] trace: reenable preemption if we modify the ip Josef Bacik
2017-12-17 19:49 ` Daniel Borkmann
2017-12-18  7:29 ` 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).