ftrace_graph_ret_addr(9)
π ftrace_graph_ret_addr(9) β or, how to un-glow-up a return address
okay bestie, welcome to the Kernel API Manual β¨ β yes, that manual, the one your kernel-dev mutuals keep quoting. today's episode: ftrace_graph_ret_addr, which returns the original value of the return address π. no cap, that's the whole NAME section, and it ate.
β¨ SYNOPSIS β¨
unsigned long ftrace_graph_ret_addr (struct task_struct *task , int *idx
, unsigned long ret , unsigned long *retp );
that's the whole signature, copy it exactly, do not come for me about the comma spacing, that's how it is in the source π
πΈ ARGUMENTS πΈ
taskβ the task the unwinder is being executed on π§ like, which poor little process are we walking the stack foridxβ an initialized pointer to the next stack index to use π it's your lil bookmark, treat it rightretβ the current return address (likely pointing toreturn_handler) π "likely" is doing a lot of work there, but slayretpβ the address on the stack of the current return location π«Ά like the home address, but for a return address
π DESCRIPTION π
okay so here's the tea β β this function gets called by stack unwinding code, and its whole job is converting a found stack return address (ret) back to its original value π₯. why? because the function graph tracer might have modified it to be 'return_to_handler' π so the address you found is giving fake identity energy and needs a reality check.
if the address hasn't been modified? iconic. the unchanged value of ret is returned, no drama, no notes π
now, idx is the main character here π β it holds the last index used to know where to start from. it should be initialized to zero for the first iteration, because zero means "start at the top of the shadow stack" β. and if the location is found, this pointer gets assigned that location, so that if you call again it'll just continue where it left off π― lowkey efficient, highkey the way that it should be.
and retp? retp is a pointer to the return address on the stack π simple, honest, doing its job.
ngl, if you're passing in an uninitialized idx on the first iteration, that's not a vibe β zero, bestie, zero π«
π SEE ALSO π
your reading list, fr fr, all of it, go off:
- Kernel file
./kernel/trace/fgraph.c fgraph_reserve_data(9)fgraph_retrieve_data(9)fgraph_get_task_var(9)fgraph_retrieve_parent_data(9)ftrace_graph_stop(9)ftrace_graph_get_ret_stack(9)ftrace_graph_top_ret_addr(9)
π sign-off π
this whole little masterpiece lives in ./kernel/trace π and it's dated October 2026 β β yes, the future, she's ahead of her time. mwah, go read the source, ily, bye π¦π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms