All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ftrace/x86: Load ftrace_ops in parameter not the variable holding it
@ 2013-11-13 20:20 Steven Rostedt
  2013-11-13 21:06 ` H. Peter Anvin
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Steven Rostedt @ 2013-11-13 20:20 UTC (permalink / raw)
  To: LKML; +Cc: H. Peter Anvin, Ingo Molnar, Thomas Gleixner, Andrew Morton


Function tracing callbacks expect to have the ftrace_ops that registered it
passed to them, not the address of the variable that holds the ftrace_ops
that registered it.

Use a mov instead of a lea to store the ftrace_ops into the parameter
of the function tracing callback.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 arch/x86/kernel/entry_32.S | 4 ++--
 arch/x86/kernel/entry_64.S | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index f0dcb0c..15a569a 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1085,7 +1085,7 @@ ENTRY(ftrace_caller)
 	pushl $0	/* Pass NULL as regs pointer */
 	movl 4*4(%esp), %eax
 	movl 0x4(%ebp), %edx
-	leal function_trace_op, %ecx
+	movl function_trace_op, %ecx
 	subl $MCOUNT_INSN_SIZE, %eax
 
 .globl ftrace_call
@@ -1143,7 +1143,7 @@ ENTRY(ftrace_regs_caller)
 	movl 12*4(%esp), %eax	/* Load ip (1st parameter) */
 	subl $MCOUNT_INSN_SIZE, %eax	/* Adjust ip */
 	movl 0x4(%ebp), %edx	/* Load parent ip (2nd parameter) */
-	leal function_trace_op, %ecx /* Save ftrace_pos in 3rd parameter */
+	movl function_trace_op, %ecx /* Save ftrace_pos in 3rd parameter */
 	pushl %esp		/* Save pt_regs as 4th parameter */
 
 GLOBAL(ftrace_regs_call)
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index b077f4c..9ce2567 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -88,7 +88,7 @@ END(function_hook)
 	MCOUNT_SAVE_FRAME \skip
 
 	/* Load the ftrace_ops into the 3rd parameter */
-	leaq function_trace_op, %rdx
+	movq function_trace_op(%rip), %rdx
 
 	/* Load ip into the first parameter */
 	movq RIP(%rsp), %rdi
-- 
1.8.1.4


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

* Re: [PATCH v2] ftrace/x86: Load ftrace_ops in parameter not the variable holding it
  2013-11-13 20:20 [PATCH v2] ftrace/x86: Load ftrace_ops in parameter not the variable holding it Steven Rostedt
@ 2013-11-13 21:06 ` H. Peter Anvin
  2013-11-13 21:17   ` Steven Rostedt
  2014-01-07 18:59   ` Steven Rostedt
  2013-11-14  4:07 ` Masami Hiramatsu
  2014-01-09 23:49 ` [tip:x86/urgent] " tip-bot for Steven Rostedt
  2 siblings, 2 replies; 6+ messages in thread
From: H. Peter Anvin @ 2013-11-13 21:06 UTC (permalink / raw)
  To: Steven Rostedt, LKML; +Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton

On 11/13/2013 12:20 PM, Steven Rostedt wrote:
> 
> Function tracing callbacks expect to have the ftrace_ops that registered it
> passed to them, not the address of the variable that holds the ftrace_ops
> that registered it.
> 
> Use a mov instead of a lea to store the ftrace_ops into the parameter
> of the function tracing callback.
> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

This looks like an urgent fix, am I correct?

	-hpa



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

* Re: [PATCH v2] ftrace/x86: Load ftrace_ops in parameter not the variable holding it
  2013-11-13 21:06 ` H. Peter Anvin
@ 2013-11-13 21:17   ` Steven Rostedt
  2014-01-07 18:59   ` Steven Rostedt
  1 sibling, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2013-11-13 21:17 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: LKML, Ingo Molnar, Thomas Gleixner, Andrew Morton

On Wed, 13 Nov 2013 13:06:33 -0800
"H. Peter Anvin" <hpa@linux.intel.com> wrote:

> On 11/13/2013 12:20 PM, Steven Rostedt wrote:
> > 
> > Function tracing callbacks expect to have the ftrace_ops that registered it
> > passed to them, not the address of the variable that holds the ftrace_ops
> > that registered it.
> > 
> > Use a mov instead of a lea to store the ftrace_ops into the parameter
> > of the function tracing callback.
> > 
> > Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> 
> This looks like an urgent fix, am I correct?
> 

It should go into 3.13 at least. I have code that will depend on this
fix, and it would be nice if it makes it into 3.13.

It's been shear luck that this hasn't caused any issues so far. That's
because the current callbacks that use its ftrace_ops don't get called
directly by assembly. If they did, they would crash due to this bug.

We should probably tag it for stable too. The bug goes back to 3.8.

Fixes: 2f5f6ad9390c1 ("ftrace: Pass ftrace_ops as third parameter to
function trace callback")

Thanks,

-- Steve

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

* Re: [PATCH v2] ftrace/x86: Load ftrace_ops in parameter not the variable holding it
  2013-11-13 20:20 [PATCH v2] ftrace/x86: Load ftrace_ops in parameter not the variable holding it Steven Rostedt
  2013-11-13 21:06 ` H. Peter Anvin
@ 2013-11-14  4:07 ` Masami Hiramatsu
  2014-01-09 23:49 ` [tip:x86/urgent] " tip-bot for Steven Rostedt
  2 siblings, 0 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2013-11-14  4:07 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, H. Peter Anvin, Ingo Molnar, Thomas Gleixner, Andrew Morton

(2013/11/14 5:20), Steven Rostedt wrote:
> 
> Function tracing callbacks expect to have the ftrace_ops that registered it
> passed to them, not the address of the variable that holds the ftrace_ops
> that registered it.
> 
> Use a mov instead of a lea to store the ftrace_ops into the parameter
> of the function tracing callback.

I see, function_trace_op is just a pointer to an actual ftrace_ops. :)
And I have ensured this change doesn't affect ftrace-kprobes since
it doesn't use this parameter.

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

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

Thank you,

> ---
>  arch/x86/kernel/entry_32.S | 4 ++--
>  arch/x86/kernel/entry_64.S | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
> index f0dcb0c..15a569a 100644
> --- a/arch/x86/kernel/entry_32.S
> +++ b/arch/x86/kernel/entry_32.S
> @@ -1085,7 +1085,7 @@ ENTRY(ftrace_caller)
>  	pushl $0	/* Pass NULL as regs pointer */
>  	movl 4*4(%esp), %eax
>  	movl 0x4(%ebp), %edx
> -	leal function_trace_op, %ecx
> +	movl function_trace_op, %ecx
>  	subl $MCOUNT_INSN_SIZE, %eax
>  
>  .globl ftrace_call
> @@ -1143,7 +1143,7 @@ ENTRY(ftrace_regs_caller)
>  	movl 12*4(%esp), %eax	/* Load ip (1st parameter) */
>  	subl $MCOUNT_INSN_SIZE, %eax	/* Adjust ip */
>  	movl 0x4(%ebp), %edx	/* Load parent ip (2nd parameter) */
> -	leal function_trace_op, %ecx /* Save ftrace_pos in 3rd parameter */
> +	movl function_trace_op, %ecx /* Save ftrace_pos in 3rd parameter */
>  	pushl %esp		/* Save pt_regs as 4th parameter */
>  
>  GLOBAL(ftrace_regs_call)
> diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
> index b077f4c..9ce2567 100644
> --- a/arch/x86/kernel/entry_64.S
> +++ b/arch/x86/kernel/entry_64.S
> @@ -88,7 +88,7 @@ END(function_hook)
>  	MCOUNT_SAVE_FRAME \skip
>  
>  	/* Load the ftrace_ops into the 3rd parameter */
> -	leaq function_trace_op, %rdx
> +	movq function_trace_op(%rip), %rdx
>  
>  	/* Load ip into the first parameter */
>  	movq RIP(%rsp), %rdi
> 


-- 
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



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

* Re: [PATCH v2] ftrace/x86: Load ftrace_ops in parameter not the variable holding it
  2013-11-13 21:06 ` H. Peter Anvin
  2013-11-13 21:17   ` Steven Rostedt
@ 2014-01-07 18:59   ` Steven Rostedt
  1 sibling, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2014-01-07 18:59 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: LKML, Ingo Molnar, Thomas Gleixner, Andrew Morton

On Wed, 13 Nov 2013 13:06:33 -0800
"H. Peter Anvin" <hpa@linux.intel.com> wrote:

> On 11/13/2013 12:20 PM, Steven Rostedt wrote:
> > 
> > Function tracing callbacks expect to have the ftrace_ops that registered it
> > passed to them, not the address of the variable that holds the ftrace_ops
> > that registered it.
> > 
> > Use a mov instead of a lea to store the ftrace_ops into the parameter
> > of the function tracing callback.
> > 
> > Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> 
> This looks like an urgent fix, am I correct?

Hi Peter, I think this patch got missed somehow. Can you pull it in.
You can also add Masami's reviewed-by tag too.

Also add the following tags:

Cc: stable@vger.kernel.org # 3.8+
Fixes: 2f5f6ad9390c1 ("ftrace: Pass ftrace_ops as third parameter to
function trace callback")

Thanks!

-- Steve

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

* [tip:x86/urgent] ftrace/x86: Load ftrace_ops in parameter not the variable holding it
  2013-11-13 20:20 [PATCH v2] ftrace/x86: Load ftrace_ops in parameter not the variable holding it Steven Rostedt
  2013-11-13 21:06 ` H. Peter Anvin
  2013-11-14  4:07 ` Masami Hiramatsu
@ 2014-01-09 23:49 ` tip-bot for Steven Rostedt
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Steven Rostedt @ 2014-01-09 23:49 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, masami.hiramatsu.pt, rostedt, tglx, hpa

Commit-ID:  1739f09e33d8f66bf48ddbc3eca615574da6c4f6
Gitweb:     http://git.kernel.org/tip/1739f09e33d8f66bf48ddbc3eca615574da6c4f6
Author:     Steven Rostedt <rostedt@goodmis.org>
AuthorDate: Wed, 13 Nov 2013 15:20:04 -0500
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 9 Jan 2014 13:24:29 -0800

ftrace/x86: Load ftrace_ops in parameter not the variable holding it

Function tracing callbacks expect to have the ftrace_ops that registered it
passed to them, not the address of the variable that holds the ftrace_ops
that registered it.

Use a mov instead of a lea to store the ftrace_ops into the parameter
of the function tracing callback.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Link: http://lkml.kernel.org/r/20131113152004.459787f9@gandalf.local.home
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: <stable@vger.kernel.org> # v3.8+
---
 arch/x86/kernel/entry_32.S | 4 ++--
 arch/x86/kernel/entry_64.S | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 51e2988..a2a4f46 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1082,7 +1082,7 @@ ENTRY(ftrace_caller)
 	pushl $0	/* Pass NULL as regs pointer */
 	movl 4*4(%esp), %eax
 	movl 0x4(%ebp), %edx
-	leal function_trace_op, %ecx
+	movl function_trace_op, %ecx
 	subl $MCOUNT_INSN_SIZE, %eax
 
 .globl ftrace_call
@@ -1140,7 +1140,7 @@ ENTRY(ftrace_regs_caller)
 	movl 12*4(%esp), %eax	/* Load ip (1st parameter) */
 	subl $MCOUNT_INSN_SIZE, %eax	/* Adjust ip */
 	movl 0x4(%ebp), %edx	/* Load parent ip (2nd parameter) */
-	leal function_trace_op, %ecx /* Save ftrace_pos in 3rd parameter */
+	movl function_trace_op, %ecx /* Save ftrace_pos in 3rd parameter */
 	pushl %esp		/* Save pt_regs as 4th parameter */
 
 GLOBAL(ftrace_regs_call)
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index e21b078..1e96c36 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -88,7 +88,7 @@ END(function_hook)
 	MCOUNT_SAVE_FRAME \skip
 
 	/* Load the ftrace_ops into the 3rd parameter */
-	leaq function_trace_op, %rdx
+	movq function_trace_op(%rip), %rdx
 
 	/* Load ip into the first parameter */
 	movq RIP(%rsp), %rdi

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

end of thread, other threads:[~2014-01-09 23:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-13 20:20 [PATCH v2] ftrace/x86: Load ftrace_ops in parameter not the variable holding it Steven Rostedt
2013-11-13 21:06 ` H. Peter Anvin
2013-11-13 21:17   ` Steven Rostedt
2014-01-07 18:59   ` Steven Rostedt
2013-11-14  4:07 ` Masami Hiramatsu
2014-01-09 23:49 ` [tip:x86/urgent] " tip-bot for Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.