]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
function_graph: Reverse the order of pushing the ret_stack and the callback
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Tue, 20 Nov 2018 17:40:25 +0000 (12:40 -0500)
committerSultan Alsawaf <sultan.alsawaf@canonical.com>
Wed, 24 Jul 2019 15:45:00 +0000 (09:45 -0600)
commiteadc9aff685146ca9bb7d18a8d586c631e3e1845
treef55bbff9678d62308bbcb53dc4f63ab2da87aca6
parent857ba6ca36cc3e8cd9cc2959b488ec8cf503137a
function_graph: Reverse the order of pushing the ret_stack and the callback

BugLink: https://bugs.launchpad.net/bugs/1836968
commit 7c6ea35ef50810aa12ab26f21cb858d980881576 upstream.

The function graph profiler uses the ret_stack to store the "subtime" and
reuse it by nested functions and also on the return. But the current logic
has the profiler callback called before the ret_stack is updated, and it is
just modifying the ret_stack that will later be allocated (it's just lucky
that the "subtime" is not touched when it is allocated).

This could also cause a crash if we are at the end of the ret_stack when
this happens.

By reversing the order of the allocating the ret_stack and then calling the
callbacks attached to a function being traced, the ret_stack entry is no
longer used before it is allocated.

Cc: stable@kernel.org
Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
kernel/trace/trace_functions_graph.c