All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing/probes: bound symstr stores to reserved length
@ 2026-11-02 11:58 Yifan Zhang
  2026-11-02 11:58 ` Yifan Zhang
  2026-11-02 12:11 ` sashiko-bot
  0 siblings, 2 replies; 3+ messages in thread
From: Yifan Zhang @ 2026-11-02 11:58 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu, linux-trace-kernel
  Cc: Mathieu Desnoyers, linux-kernel

Traceprobe calculates dynamic string sizes before storing the values.  A
probed pointer can change between those passes, so fetch_store_symstrlen()
can reserve space for a short symbol while fetch_store_symstring() observes
a longer one.  The store path reads the reserved length but ignores it and
uses sprint_symbol(), allowing the second symbol to overwrite the trace
record.

KASAN reports:

  BUG: KASAN: slab-out-of-bounds in sized_strscpy
  Write of size 8
  sized_strscpy
  module_address_lookup
  __sprint_symbol
  process_fetch_insn

Format the symbol using the reserved length as the destination bound.

The patched kernel completes the same pointer-switching workload without a
KASAN report.

Fixes: b26a124cbfa8 ("tracing/probes: Add symstr type for dynamic events")
Signed-off-by: Yifan Zhang <yfzhang23@stu.pku.edu.cn>
---
 kernel/trace/trace_probe_tmpl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h
index 8db12f758fdae..cc317cb444e43 100644
--- a/kernel/trace/trace_probe_tmpl.h
+++ b/kernel/trace/trace_probe_tmpl.h
@@ -95,7 +95,7 @@ fetch_store_symstring(unsigned long addr, void *dest, void *base)
 
 	__dest = get_loc_data(dest, base);
 
-	return sprint_symbol(__dest, addr);
+	return scnprintf(__dest, maxlen, "%pS", (void *)addr) + 1;
 }
 
 /* common part of process_fetch_insn*/
-- 
2.39.5 (Apple Git-154)

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

end of thread, other threads:[~2026-11-02 12:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 11:58 [PATCH] tracing/probes: bound symstr stores to reserved length Yifan Zhang
2026-11-02 11:58 ` Yifan Zhang
2026-11-02 12:11 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.