]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tracing: probes: Fix a possible race in trace_probe_log APIs
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Sat, 10 May 2025 03:44:41 +0000 (12:44 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 May 2025 12:12:12 +0000 (14:12 +0200)
commit70417bada46dcfb91b59757bad343f753d9d9345
tree87429b685772900fd887c13c383457740a3b52ec
parent4e63b6907d07a5561816a30ee26ec7d42193164e
tracing: probes: Fix a possible race in trace_probe_log APIs

[ Upstream commit fd837de3c9cb1a162c69bc1fb1f438467fe7f2f5 ]

Since the shared trace_probe_log variable can be accessed and
modified via probe event create operation of kprobe_events,
uprobe_events, and dynamic_events, it should be protected.
In the dynamic_events, all operations are serialized by
`dyn_event_ops_mutex`. But kprobe_events and uprobe_events
interfaces are not serialized.

To solve this issue, introduces dyn_event_create(), which runs
create() operation under the mutex, for kprobe_events and
uprobe_events. This also uses lockdep to check the mutex is
held when using trace_probe_log* APIs.

Link: https://lore.kernel.org/all/174684868120.551552.3068655787654268804.stgit@devnote2/
Reported-by: Paul Cacheux <paulcacheux@gmail.com>
Closes: https://lore.kernel.org/all/20250510074456.805a16872b591e2971a4d221@kernel.org/
Fixes: ab105a4fb894 ("tracing: Use tracing error_log with probe events")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/trace/trace_dynevent.c
kernel/trace/trace_dynevent.h
kernel/trace/trace_kprobe.c
kernel/trace/trace_probe.c
kernel/trace/trace_uprobe.c