perf: Stop stack frame walking off kernel addresses boundaries
Subsystems (2)
PATCH 1/1 perf: Stop stack frame walking off kernel addresses boundaries
While processing kernel perf callchains, an bad entry can be considered as a valid stack pointer but not as a kernel address.
In this case, we hang in an endless loop. This can happen in an x86-32 kernel after processing the last entry in a kernel stacktrace.
Just stop the stack frame walking after we encounter an invalid kernel address.
This fixes a hard lockup in x86-32.
--- arch/x86/kernel/dumpstack.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
arch/x86/kernel/dumpstack.c +8 -6
@@ -123,13 +123,15 @@ print_context_stack_bp(struct thread_info *tinfo,while (valid_stack_ptr (tinfo, ret_addr,sizeof (*ret_addr), end)) {unsigned long addr = *ret_addr; -if (__kernel_text_address (addr)) { - ops->address (data, addr,1 ); - frame = frame->next_frame; - ret_addr = &frame->return_address; -print_ftrace_graph_addr (addr, data, ops, tinfo, graph); - } +if (!__kernel_text_address (addr)) +break ; + + ops->address (data, addr,1 ); + frame = frame->next_frame; + ret_addr = &frame->return_address; +print_ftrace_graph_addr (addr, data, ops, tinfo, graph); } +return (unsigned long )frame; }EXPORT_SYMBOL_GPL (print_context_stack_bp);
Signature · 1 line
1.6.2.3
Commit-ID: c2c5d45d46c8c0fd34291dec958670ad4816796f Gitweb: http://git.kernel.org/tip/c2c5d45d46c8c0fd34291dec958670ad4816796f Author: Frederic Weisbecker <[email protected]> AuthorDate: Thu, 31 Dec 2009 03:52:25 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 13 Jan 2010 09:32:54 +0100
perf: Stop stack frame walking off kernel addresses boundaries
While processing kernel perf callchains, an bad entry can be considered as a valid stack pointer but not as a kernel address.
In this case, we hang in an endless loop. This can happen in an x86-32 kernel after processing the last entry in a kernel stacktrace.
Just stop the stack frame walking after we encounter an invalid kernel address.
This fixes a hard lockup in x86-32.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/dumpstack.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
arch/x86/kernel/dumpstack.c +8 -6
@@ -123,13 +123,15 @@ print_context_stack_bp(struct thread_info *tinfo,while (valid_stack_ptr (tinfo, ret_addr,sizeof (*ret_addr), end)) {unsigned long addr = *ret_addr; -if (__kernel_text_address (addr)) { - ops->address (data, addr,1 ); - frame = frame->next_frame; - ret_addr = &frame->return_address; -print_ftrace_graph_addr (addr, data, ops, tinfo, graph); - } +if (!__kernel_text_address (addr)) +break ; + + ops->address (data, addr,1 ); + frame = frame->next_frame; + ret_addr = &frame->return_address; +print_ftrace_graph_addr (addr, data, ops, tinfo, graph); } +return (unsigned long )frame; }EXPORT_SYMBOL_GPL (print_context_stack_bp);