Re: [PATCH v2] fork: initialize function graph state before copy_exec_state()

From: Jérémy Jean

Date: Sat Aug 22 2026 - 15:56:56 EST


On 2026-08-22 17:22, Steven Rostedt wrote:
On Sat, 22 Aug 2026 08:49:27 +0000
Jérémy Jean <Jeremy.Jean@xxxxxxxxxxxxxxxxx> wrote:

dup_task_struct() copies the parent's task_struct, including ret_stack.
ftrace_graph_init_task() clears the copied function graph state, but it
currently runs after copy_exec_state().

For non-CLONE_VM forks, copy_exec_state() allocates a new task_exec_state.
If that allocation fails, copy_process() reaches bad_fork_free and
free_task() calls ftrace_graph_exit_task(). Since the child still carries
the parent's ret_stack pointer, the unwind frees the parent's active
function graph return stack. The parent subsequently accesses freed memory
from function_graph_enter_regs().


As this effects function_graph tracing, please resend and Cc:
linux-trace-kernel@xxxxxxxxxxxxxxx so that it gets to the proper
patchwork. It will need to go through my tree so that it gets the
proper testing.

Hello Steve,

Done. Thanks for the feedback.
Let me know if I can help more.

Regards,
Jérémy