Skip to content

Commit 2013e8c

Browse files
committed
Merge tag 'trace-v6.16-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing fixes from Steven Rostedt: - 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 it is held when iterating the list. * tag 'trace-v6.16-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing: Add down_write(trace_event_sem) when adding trace event tracing/osnoise: Fix crash in timerlat_dump_stack()
2 parents c10ee5c + b5e8acc commit 2013e8c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

kernel/trace/trace_events.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3136,7 +3136,10 @@ __register_event(struct trace_event_call *call, struct module *mod)
31363136
if (ret < 0)
31373137
return ret;
31383138

3139+
down_write(&trace_event_sem);
31393140
list_add(&call->list, &ftrace_events);
3141+
up_write(&trace_event_sem);
3142+
31403143
if (call->flags & TRACE_EVENT_FL_DYNAMIC)
31413144
atomic_set(&call->refcnt, 0);
31423145
else
@@ -3750,6 +3753,8 @@ __trace_add_event_dirs(struct trace_array *tr)
37503753
struct trace_event_call *call;
37513754
int ret;
37523755

3756+
lockdep_assert_held(&trace_event_sem);
3757+
37533758
list_for_each_entry(call, &ftrace_events, list) {
37543759
ret = __trace_add_new_event(call, tr);
37553760
if (ret < 0)

kernel/trace/trace_osnoise.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,8 @@ __timerlat_dump_stack(struct trace_buffer *buffer, struct trace_stack *fstack, u
637637

638638
entry = ring_buffer_event_data(event);
639639

640-
memcpy(&entry->caller, fstack->calls, size);
641640
entry->size = fstack->nr_entries;
641+
memcpy(&entry->caller, fstack->calls, size);
642642

643643
trace_buffer_unlock_commit_nostack(buffer, event);
644644
}

0 commit comments

Comments
 (0)