Re: [PATCH 0/2] tracepoint: Fix stale probe data in system call tracepoints

From: Andrea Parri

Date: Fri Dec 04 2026 - 10:51:51 EST


On Fri, Dec 04, 2026 at 10:41:13AM -0500, Mathieu Desnoyers wrote:
> Why not just fix tp_rcu_cond_sync() to handle the rcu tasks trace
> sychronization which seems to be missing ?

That was my first version: tp_rcu_get_state() also took a polled
snapshot of rcu_tasks_trace_srcu_struct for faultable tracepoints, and
tp_rcu_cond_sync() waited for it if it had not elapsed yet. It closes
the race, but the wait runs under tracepoints_mutex, and the read-side
sections of the system call tracepoints are not bounded: their probes
can fault in user memory, and sleepable BPF programs can attach there
too. How long a fault takes is up to whoever backs the memory, a
userfaultfd handler for example.

With a sys_enter_write probe parked in a userfaultfd fault, I disabled
that event and then attached a BPF raw tracepoint to sched_switch. The
attach blocked until the fault was resolved (it was still blocked after
3 s, on v7.4-rc4):

__synchronize_srcu+0x92/0xd0
tracepoint_add_func+0x2b5/0x480
tracepoint_probe_register_prio_may_exist+0x6d/0xa0
bpf_raw_tp_link_attach+0x1c2/0x2a0

The snapshots are shared by all tracepoints, so the wait also hits
registrations on unrelated tracepoints such as sched_switch. Keeping
the Tasks Trace snapshot per tracepoint would avoid that, but a
sys_enter or sys_exit registration could still sleep on the fault with
tracepoints_mutex held, and every other probe registration and
unregistration would queue behind it.

Keeping the iterator for faultable tracepoints removes the need for
that wait, at the cost of an indirect call while the tracepoint has a
single probe.

Thanks,
Andrea