Skip to contentSkip to conversation

tracing: Fixes for 6.16

GIT PULL Merged Steven Rostedt 2 participants 2 messages Jul 20, 2025

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

Linus,

Tracing fixes for 6.16:

- Fix timerlat with use of FORTIFY_SOURCE

FORTIFY_SOURCE was added to the stack tracer where it compares the entry->caller array to having entry->size elements.

timerlat has the following:

     memcpy(&entry->caller, fstack->calls, size);
     entry->size = size;

Which triggers FORTIFY_SOURCE as the caller is populated before the entry->size is initialized.

Swap the order to satisfy FORTIFY_SOURCE logic.

- Add down_write(trace_event_sem) when adding trace events in modules

Trace events being added to the ftrace_events array are protected by the trace_event_sem semaphore. But when loading modules that have trace events, the addition of the events are not protected by the semaphore and loading two modules that have events at the same time can corrupt the list.

Also add a lockdep_assert_held(trace_event_sem) to _trace_add_event_dirs() to confirm its held when iterating the list.

Please pull the latest trace-v6.16-rc5 tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace-v6.16-rc5

Tag SHA1: 3fa4ea79493691015e6e08d752e502a80d3364a6 Head SHA1: b5e8acc14dcb314a9b61ff19dcd9fdd0d88f70df

Steven Rostedt (1):
tracing: Add down_write(trace_event_sem) when adding trace event

Tomas Glozar (1):
tracing/osnoise: Fix crash in timerlat_dump_stack()

----

 kernel/trace/trace_events.c  | 5 +++++
 kernel/trace/trace_osnoise.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

---------------------------

kernel/trace/trace_events.c +5 -0
index 120531268abf..d01e5c910ce1 100644
@@ -3136,7 +3136,10 @@ __register_event(struct trace_event_call *call, struct module *mod)
 	if (ret < 0)
 		return ret;
 
+	down_write(&trace_event_sem);
 	list_add(&call->list, &ftrace_events);
+	up_write(&trace_event_sem);
+
 	if (call->flags & TRACE_EVENT_FL_DYNAMIC)
 		atomic_set(&call->refcnt, 0);
 	else
@@ -3750,6 +3753,8 @@ __trace_add_event_dirs(struct trace_array *tr)
 	struct trace_event_call *call;
 	int ret;
 
+	lockdep_assert_held(&trace_event_sem);
+
 	list_for_each_entry(call, &ftrace_events, list) {
 		ret = __trace_add_new_event(call, tr);
 		if (ret < 0)
kernel/trace/trace_osnoise.c +1 -1
index 6819b93309ce..fd259da0aa64 100644
@@ -637,8 +637,8 @@ __timerlat_dump_stack(struct trace_buffer *buffer, struct trace_stack *fstack, u
 
 	entry = ring_buffer_event_data(event);
 
-	memcpy(&entry->caller, fstack->calls, size);
 	entry->size = fstack->nr_entries;
+	memcpy(&entry->caller, fstack->calls, size);
 
 	trace_buffer_unlock_commit_nostack(buffer, event);
 }
merge bot Merged
#1 lore raw
The pull request you sent on Sun, 20 Jul 2025 14:53:39 -0400:

The pull request you sent on Sun, 20 Jul 2025 14:53:39 -0400:

Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git trace-v6.16-rc5

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/2013e8c2e6fd3a4bdf4ccc658ad20a4469360eff

Thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html