Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH 0/2] tracepoint: Fix stale probe data in system call tracepoints
@ 2026-12-04 15:34 Andrea Parri
  2026-12-04 15:34 ` [PATCH 1/2] tracepoint: Always use the iterator for faultable tracepoints Andrea Parri
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andrea Parri @ 2026-12-04 15:34 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu
  Cc: Mathieu Desnoyers, linux-kernel, linux-trace-kernel, bpf

System call tracepoints protect their probes with RCU Tasks Trace
only, but switching a static call to a single probe waits only for RCU
and tracepoint_srcu readers.  A preempted reader can then call the new
probe with the old probe's data, and crash in ftrace_syscall_enter() or
bpf_trace_run2().

Patch 1 fixes this by keeping the static call of faultable tracepoints
on __traceiter_*(), which loads each probe together with its data.

Patch 2 drops what faultable tracepoints no longer need: the static
call update and the grace period snapshots and waits.  Patch 1 alone
fixes the bug, so patch 2 can wait for the next merge window, or be
squashed into patch 1 if that is preferred.

Tested on v7.4-rc5 in x86-64 KVM guests, with the test-only hook below
the --- of patch 1, which also has the reproducer for 2 -> 1.  Both
race sequences oops in 3 of 3 runs without the series, and in none
with patch 1 alone or with both patches.  ftracetest: 164 passed,
0 failed in all three cases.

With perf_syscall_enter() as the only sys_enter probe, getppid() takes
153.6 ns with the series and 153.2 ns without it.  With patch 1 alone,
whose reader path is the same, another pair of builds measured 155.9
and 153.7 ns: a difference of 2.2 ns, against 0.4 ns for the series.

The bug was found with the help of an LLM, which was also used to write
both patches, their changelogs and the tests.

Andrea Parri (2):
  tracepoint: Always use the iterator for faultable tracepoints
  tracepoint: Drop static call switching for faultable tracepoints

 kernel/tracepoint.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

-- 
2.53.0


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

end of thread, other threads:[~2026-12-04 15:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 15:34 [PATCH 0/2] tracepoint: Fix stale probe data in system call tracepoints Andrea Parri
2026-12-04 15:34 ` [PATCH 1/2] tracepoint: Always use the iterator for faultable tracepoints Andrea Parri
2026-12-04 15:34 ` [PATCH 2/2] tracepoint: Drop static call switching " Andrea Parri
2026-12-04 15:41 ` [PATCH 0/2] tracepoint: Fix stale probe data in system call tracepoints Mathieu Desnoyers
2026-12-04 15:51   ` Andrea Parri

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