]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
tracing: Fix an unallocated memory access in function_graph
authorShaohua Li <shaohua.li@intel.com>
Tue, 27 Jul 2010 08:06:34 +0000 (16:06 +0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 26 Aug 2010 23:45:48 +0000 (16:45 -0700)
commit 575570f02761bd680ba5731c1dfd4701062e7fb2 upstream.

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.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/trace/trace_functions_graph.c

index 79f4bac99a94a767569a8247091eb7fd196fae7b..b4c179ae4e45019e4f73c10ac21cd26fa4219192 100644 (file)
@@ -507,7 +507,15 @@ get_return_for_leaf(struct trace_iterator *iter,
                         * if the output fails.
                         */
                        data->ent = *curr;
-                       data->ret = *next;
+                       /*
+                        * If the next event is not a return type, then
+                        * we only care about what type it is. Otherwise we can
+                        * safely copy the entire event.
+                        */
+                       if (next->ent.type == TRACE_GRAPH_RET)
+                               data->ret = *next;
+                       else
+                               data->ret.ent.type = next->ent.type;
                }
        }