mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fprobe: Clear the unused part of the fgraph_data reservation
@ 2026-09-11 19:55 David Carlier
  2026-09-15  8:53 ` Martin Kaiser
  2026-09-16 23:08 ` Masami Hiramatsu
  0 siblings, 2 replies; 3+ messages in thread
From: David Carlier @ 2026-09-11 19:55 UTC (permalink / raw)
  To: Masami Hiramatsu, Steven Rostedt
  Cc: Mathieu Desnoyers, Martin Kaiser, linux-trace-kernel,
	linux-kernel, David Carlier, stable

fprobe_fgraph_entry() reserves shadow stack space for every fprobe with
an exit handler, but only fills it for those whose entry handler returns
0. fprobe_return() walks the whole reservation, so the unused tail is
parsed as stale headers from an earlier call, and an exit handler can
run twice or despite its entry handler asking to skip it.

The original memset cleared only (reserved_words - used) bytes, and
commit e0a384434ae1 ("tracing: fprobe: do not zero out unused
fgraph_data") removed it. Clear the whole tail.

Fixes: 4346ba160409 ("fprobe: Rewrite fprobe on function-graph tracer")
Cc: stable@vger.kernel.org
Signed-off-by: David Carlier <devnexen@gmail.com>
---
 kernel/trace/fprobe.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
index 1e9b00997ff2..bd84a982961a 100644
--- a/kernel/trace/fprobe.c
+++ b/kernel/trace/fprobe.c
@@ -635,6 +635,10 @@ static int fprobe_fgraph_entry(struct ftrace_graph_ent *trace, struct fgraph_ops
 		}
 	}
 
+	/* Clear unused slots so fprobe_return() does not see stale headers. */
+	if (used < reserved_words)
+		memset(fgraph_data + used, 0, (reserved_words - used) * sizeof(long));
+
 	/* If any exit_handler is set, data must be used. */
 	return used != 0;
 }
-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-16 23:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 19:55 [PATCH] fprobe: Clear the unused part of the fgraph_data reservation David Carlier
2026-09-15  8:53 ` Martin Kaiser
2026-09-16 23:08 ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®