tracing: Fixes for v7.2
Subsystems (3)
Linus,
tracing fixes for v7.2:
- Reset dropped_count in mmio_reset_data()
When mmio_reset_data() is called, it does not reset the dropped_count so that subsequent runs will have incorrect reporting.
- Add NULL check for mmio_trace_array in logging functions
The functions __trace_mmiotrace_rw() and __trace_mmiotrace_map() may have the 'tr' variable passed to it as NULL. But they both dereference it without checking if it is NULL first.
- Check return value of __register_event() in trace_module_add_events()
If __register_event() fails, the call after it (__add_event_to_tracers()) will create a file for it. If the module fails to load and its memory is freed, the file will still point to it and it will not be removed as the registering of the event did not complete. Only call __add_event_to_tracers() if the __register_event() was successful.
- Fix false positive match in regex_match_full()
The regex full matching uses a strncmp() to test against the match string and the value. It should not match if value is a prefix of the string to match. Check to make sure the length of the strings match before comparing.
- Fix reader page read offset for remote buffers
A page swapped in by __rb_get_reader_page_from_remote() retains its stale read offset, causing subsequent reads to skip events or read past valid data.
- Fix memory leak of subbuf_ids in rb_allocate_cpu_buffer()
Remote buffers allocate a subbuf_ids array. If the allocator function fails after it is allocated, it does not free it, resulting in a memory leak.
Please pull the latest trace-v7.2-rc5 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace-v7.2-rc5
Tag SHA1: f07a8527f1050765a6684e0f0fac7cc6a3ead4b0 Head SHA1: 260b20d9b78bf002f89088fb62d60e8dee98f6f8
Masami Hiramatsu (Google) (5):
tracing/mmiotrace: Reset dropped_count in mmio_reset_data() tracing/mmiotrace: Add NULL check for mmio_trace_array in logging functions
tracing: Check return value of __register_event() in trace_module_add_events() tracing/filters: Fix false positive match in regex_match_full()
ring-buffer: Fix subbuf_ids memory leak in rb_allocate_cpu_buffer() error path
Vincent Donnefort (1):
ring-buffer: Fix reader page read offset for remote buffers
----
kernel/trace/ring_buffer.c | 2 ++ kernel/trace/trace_events.c | 4 ++-- kernel/trace/trace_events_filter.c | 3 +++ kernel/trace/trace_mmiotrace.c | 13 +++++++++++-- 4 files changed, 18 insertions(+), 4 deletions(-)
---------------------------
kernel/trace/ring_buffer.c +2 -0
@@ -2599,6 +2599,7 @@ rb_allocate_cpu_buffer(struct trace_buffer *buffer, long nr_pages, int cpu)return_ptr (cpu_buffer); fail_free_reader: +kfree (cpu_buffer->subbuf_ids);free_buffer_page (cpu_buffer->reader_page);return NULL ;
@@ -5783,6 +5784,7 @@ __rb_get_reader_page_from_remote(struct ring_buffer_per_cpu *cpu_buffer) cpu_buffer->head_page = new_head; cpu_buffer->reader_page = new_reader; + cpu_buffer->reader_page->read =0 ; cpu_buffer->pages = &new_head->list; cpu_buffer->read_stamp = new_reader->page->time_stamp; cpu_buffer->lost_events = cpu_buffer->meta_page->reader.lost_events;
kernel/trace/trace_events.c +2 -2
@@ -3933,8 +3933,8 @@ static void trace_module_add_events(struct module *mod) end = mod->trace_events + mod->num_trace_events;for_each_event (call, start, end) { -__register_event (*call, mod); -__add_event_to_tracers (*call); +if (!__register_event (*call, mod)) +__add_event_to_tracers (*call); }update_cache_events (mod);
kernel/trace/trace_events_filter.c +3 -0
@@ -1027,6 +1027,9 @@ static int regex_match_full(char *str, struct regex *r, int len)if (!len)return strcmp (str, r->pattern) ==0 ; +if (len < r->len) +return 0 ; +return strncmp (str, r->pattern, len) ==0 ; }
kernel/trace/trace_mmiotrace.c +11 -2
@@ -29,6 +29,7 @@ static void mmio_reset_data(struct trace_array *tr) { overrun_detected = false; prev_overruns =0 ; +atomic_set (&dropped_count,0 );tracing_reset_online_cpus (&tr->array_buffer); }
@@ -293,11 +294,15 @@ device_initcall(init_mmio_trace);static void __trace_mmiotrace_rw (struct trace_array *tr,struct mmiotrace_rw *rw) { -struct trace_buffer *buffer = tr->array_buffer.buffer; +struct trace_buffer *buffer;struct ring_buffer_event *event;struct trace_mmiotrace_rw *entry;unsigned int trace_ctx; +if (!tr) +return ; + + buffer = tr->array_buffer.buffer; trace_ctx =tracing_gen_ctx_flags (0 ); event =trace_buffer_lock_reserve (buffer,TRACE_MMIO_RW ,sizeof (*entry), trace_ctx);
@@ -320,11 +325,15 @@ void mmio_trace_rw(struct mmiotrace_rw *rw)static void __trace_mmiotrace_map (struct trace_array *tr,struct mmiotrace_map *map) { -struct trace_buffer *buffer = tr->array_buffer.buffer; +struct trace_buffer *buffer;struct ring_buffer_event *event;struct trace_mmiotrace_map *entry;unsigned int trace_ctx; +if (!tr) +return ; + + buffer = tr->array_buffer.buffer; trace_ctx =tracing_gen_ctx_flags (0 ); event =trace_buffer_lock_reserve (buffer,TRACE_MMIO_MAP ,sizeof (*entry), trace_ctx);
The pull request you sent on Fri, 31 Jul 2026 20:44:42 -0400:
The pull request you sent on Fri, 31 Jul 2026 20:44:42 -0400:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.gittrace-v7.2-rc5
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/2aa6a5e889594687d6617f9a0cc8a288ac236852
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html