summaryrefslogtreecommitdiff
path: root/rust/alloc/vec
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2026-11-24 09:24:47 -0500
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>2026-11-25 23:12:25 +0900
commit23c8af89aac3feb3867c5eb47aca5b3a2dccb70e (patch)
tree22883bf3d5adc7743c733c965a854cbae9b0dc38 /rust/alloc/vec
parent49276f7c85ba1c140b2605b816a2596d02b36ba4 (diff)
tracing/probes: Zero out faulted dereferenced fields
While looking at tasks global descriptor tables, I discovered the following anomaly: ~# echo 't:sched sched_switch prev=prev mm=(task_struct)prev->mm ppgd=(task_struct)prev->mm->pgd' > /sys/kernel/tracing/dynamic_events The above creates a tprobe on the sched_switch tracepoint and records the previous task_struct pointer, it's mm_struct and the pgd the mm_struct points to. ~# trace-cmd start -e tracepoints:sched bash-1050 [000] d..3. 90.829478: sched: (__probestub_sched_switch+0x0/0x10) prev=0xffff88d30b623600 mm=0xffff88d30108c600 ppgd=0xffff88d33352b000 <idle>-0 [002] d..3. 90.836024: sched: (__probestub_sched_switch+0x0/0x10) prev=0xffff88d301870000 mm=0x0 ppgd=0x0 rcu_preempt-15 [002] d..3. 90.836031: sched: (__probestub_sched_switch+0x0/0x10) prev=0xffff88d3013ad100 mm=0x0 ppgd=0xffff88d33352b000 The first event has is a user task that has both a valid mm_struct and a pgd. The second event is a kernel task where the mm_struct is NULL and so is the dereferenced pgd pointer. The third event is where things looked strange. The mm_struct is NULL but the dereferenced pgd has a value! That is: NULL->pgd produced something other than zero. The reason for this is that the probe_mem_read() and probe_mem_read_user() do not write to the destination on failure. The process_fetch_insn_bottom() loop does not check the return value of the dereference (as it is the last one), and does not update the event. That leaves the value for that failed field to be whatever was in the ring buffer at that time. Have both probe_mem_read() and probe_mem_read_user() set the destination to zero on failure to read the address. Now all pgd are zero when mm is zero. Also update the stage 2 of process_fetch_insn_bottom() to not return on fault but to just set the value to zero and also do not even bother dereferencing the address if the value is already zero. This allows the code to continue and fill in the zero into the memory location on the ring buffer. Link: https://lore.kernel.org/all/20261124092447.4dbf5233@gandalf.local.home/ Cc: stable@vger.kernel.org Fixes: 533059281ee59 ("tracing: probeevent: Introduce new argument fetching code") Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Diffstat (limited to 'rust/alloc/vec')
0 files changed, 0 insertions, 0 deletions