ftrace/x86: Load ftrace_ops in parameter not the variable holding it
PATCH v2 1/1 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.
--- arch/x86/kernel/entry_32.S | 4 ++-- arch/x86/kernel/entry_64.S | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/entry_32.S +2 -2
@@ -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)
arch/x86/kernel/entry_64.S +1 -1
@@ -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
Signature · 1 line
1.8.1.4
Quoted 9 lines · Steven Rostedt
Function tracing callbacks expect to have the
ftrace_opsthat registered it passed to them, not the address of the variable that holds theftrace_opsthat registered it.Use a mov instead of a lea to store the
ftrace_opsinto the parameter of the function tracing callback.Signed-off-by Steven Rostedt <[email protected]>
This looks like an urgent fix, am I correct?
-hpa
Quoted 6 lines · On Wed, 13 Nov 2013 13:06:33 -0800 "H. Peter Anvin" <[email protected]> wrote:
Quoted 5 lines · Steven Rostedt
Function tracing callbacks expect to have the
ftrace_opsthat registered it passed to them, not the address of the variable that holds theftrace_opsthat registered it.
Quoted 7 lines
Quoted 4 lines
Use a mov instead of a lea to store the
ftrace_opsinto the parameter of the function tracing callback.Signed-off-by Steven Rostedt <[email protected]>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.
function trace callback")
Thanks,
-- Steve
Quoted 6 lines · On Wed, 13 Nov 2013 13:06:33 -0800 "H. Peter Anvin" <[email protected]> wrote:
Quoted 5 lines · Steven Rostedt
Function tracing callbacks expect to have the
ftrace_opsthat registered it passed to them, not the address of the variable that holds theftrace_opsthat registered it.
Quoted 6 lines
Quoted 4 lines
Use a mov instead of a lea to store the
ftrace_opsinto the parameter of the function tracing callback.Signed-off-by Steven Rostedt <[email protected]>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:
function trace callback")
Thanks!
-- Steve
Quoted 7 lines · Steven Rostedt
Function tracing callbacks expect to have the
ftrace_opsthat registered it passed to them, not the address of the variable that holds theftrace_opsthat registered it.Use a mov instead of a lea to store the
ftrace_opsinto 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.
Quoted 1 line
Signed-off-by Steven Rostedt <[email protected]>
Thank you,
Quoted 41 lines
--- arch/x86/kernel/entry_32.S | 4 ++-- arch/x86/kernel/entry_64.S | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)arch/x86/kernel/entry_32.S +2
-2@@ -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)arch/x86/kernel/entry_64.S +1
-1@@ -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
Signature · 4 lines
Masami HIRAMATSU IT Management Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]
tip-bot for Steven Rostedt
merge botftrace/x86: Load ftrace_ops in parameter not the variable holding it
Commit-ID: 1739f09e33d8f66bf48ddbc3eca615574da6c4f6 Gitweb: http://git.kernel.org/tip/1739f09e33d8f66bf48ddbc3eca615574da6c4f6 Author: Steven Rostedt <[email protected]> AuthorDate: Wed, 13 Nov 2013 15:20:04 -0500 Committer: H. Peter Anvin <[email protected]> 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.
--- arch/x86/kernel/entry_32.S | 4 ++-- arch/x86/kernel/entry_64.S | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/entry_32.S +2 -2
@@ -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)
arch/x86/kernel/entry_64.S +1 -1
@@ -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