Skip to content

Commit 575570f

Browse files
Shaohua Lirostedt
authored andcommitted
tracing: Fix an unallocated memory access in function_graph
With CONFIG_DEBUG_PAGEALLOC, I observed an unallocated memory access in function_graph trace. It appears we find a small size entry in ring buffer, but we access it as a big size entry. The access overflows the page size and touches an unallocated page. Cc: <stable@kernel.org> Signed-off-by: Shaohua Li <shaohua.li@intel.com> LKML-Reference: <1280217994.32400.76.camel@sli10-desk.sh.intel.com> [ Added a comment to explain the problem - SDR ] Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 8a4fd31 commit 575570f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎kernel/trace/trace_functions_graph.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,15 @@ get_return_for_leaf(struct trace_iterator *iter,
507507
* if the output fails.
508508
*/
509509
data->ent = *curr;
510-
data->ret = *next;
510+
/*
511+
* If the next event is not a return type, then
512+
* we only care about what type it is. Otherwise we can
513+
* safely copy the entire event.
514+
*/
515+
if (next->ent.type == TRACE_GRAPH_RET)
516+
data->ret = *next;
517+
else
518+
data->ret.ent.type = next->ent.type;
511519
}
512520
}
513521

0 commit comments

Comments
 (0)