linux/kernel/trace
Linus Torvalds e2c278bc37 tracing fixes for v7.3:
- Fix NULL dereference when copying histogram field variable
 
   If event_hist_trigger_parse() creates an action that uses one of pseudo
   fields for its keys, the hist_data field element will have a NULL for its
   field member. When looking to match that key, the lookup uses
   key_field->field->name which will dereference a NULL pointer.
   Instead use the helper function that handles such cases: expr_field_str().
 
 - Take the trace_types_lock when dropping the buffer_meta reference
 
   The tracing_buffer_meta_open() error return drops the trace_array
   reference with __trace_array_put() instead of trace_array_put() where the
   former doesn't take the lock and the latter does.
 
 - Fix NULL pointer dereference when reading per_cpu/cpuN/buffer_meta
 
   These files are created for every possible CPU. But it only contains data
   for CPUs that have come online. If one is read for a CPU that hasn't come
   online yet, it triggers a NULL pointer dereference.
 
   Have reading of CPUs that have not come on line yet return -ENODEV.
 
 - Fix an out-of-bounds shift in the log2 histogram modifier
 
   Histograms can take a log2 modifier to have the buckets defined by log2
   increments. If a shift is greater than ULONG_MAX or above 2^63, the key
   falls into a lower order bucket.
 
   Use order_base_2() instead of "ilog2(n - 1) + 1" to have all overflowed
   keys go into the top bucket.
 
 - Fix the persistent ring buffer rb_meta_subbuf_idx() accounting
 
   The algorithm for finding the index of a sub-buffer in a persistent ring
   buffer buffer did not take into account the meta data at the beginning of
   the buffer causing the wrong index to be returned.
 
   As rb_subbufs_from_meta() does the proper accounting to find the first
   sub-buffer, use that function instead of repeating the logic (incorrectly)
   and make the calculations based off of that.
 
 - Fix the symbol name checks for the remote buffer code
 
   The remote ring buffer has a build time check to make sure its not using
   any code that will not be in the hypervisor. For various architectures,
   there has been false positive reports from this checker.
 
   Fix them.
 
 - Fix false warning in ring_buffer_map_get_reader()
 
   There is a WARN_ON() after rb_get_reader_page() if no reader is returned.
   But there are legitimate cases where this can happen. Remove the WARN_ON()
   and also a check that covers one of the legitimate cases that tries to
   exit out early. There's no need for the check if it just simply allows the
   return of NULL from rb_get_reader_page().
 
 - Fix the ignored return value from resize_buffer_duplicate_size()
 
   Some clean up of the code in tracing_snapshot_write() removed checking the
   return value of resize_buffer_duplicate_size() and if that failed it would
   not be detected.
 
 - Fix the histogram timestamps for buffered events
 
   The histogram timestamps are taken from the events that are recorded.
   It currently reads ring_buffer_event_time_stamp() but if the event is
   buffered it does not read it properly. Use tracing_event_time_stamp()
   which handles both buffered and normal events.
 
 - Do not initialize tracefs if tracing is disabled at boot
 
   If tracing fails to allocate or some other error is detected,
   tracing_disabled is set. Do not initialize tracefs in this case as it may
   expect data to be initialized but is not.
 
 - Free eventfs inode after an RCU grace period
 
   Currently eventfs_inodes are freed after a SRCU grace period as the
   iterations in the code use SRCU. There are locations that the inode may
   still be accessed from the VFS that uses RCU which does not have the same
   synchronization as SRCU. Add an RCU wait before free eventfs inodes.
 
 - Do not fail persistent and remote buffers under memory pressure
 
   As persistent and remote buffers have their own pre-allocated memory,
   there's no reason to check how much memory is available before created
   them. By checking the memory pressure, these buffers may fail to be
   created even though their memory is already present.
 
 - Account for subbuffer size when checking how much memory is available
 
   Before allocating a ring buffer, the size is checked against the current
   memory pressure of the system. But it assumes every sub-buffer is of page
   size. This is no longer the case. Use the actual sub-buffer size when
   calculating how much memory will be used.
 
 - Reject non-stack fields for synthetic stacktrace fields
 
   Stack traces are special fields and the checks currently do not do enough
   to make sure that the fields being processed as stack traces are indeed
   stack traces. Update the logic to properly detect what is or is not a
   stack trace.
 
 - Fix a crash in print_graph_function_event()
 
   When a tracer does not define static or default flags the
   tr->current_trace_flags is set to NULL. If the ring buffer is
   not cleared when switching tracers, the previous tracers events
   could be read. The function_graph entries will dereference the
   tr->current_trace_flags and cause a crash.
 
   Set the tr->current_trace_flags to a empty set of flags to prevent
   it from being NULL.
 
 - Separate tracing filter predicate count from allocation
 
   The amount allocated for the predicate program is the number of predicates
   defined plus two for adding "true" and "false" at the end. The nr_preds is
   incremented by two to accommodate the booleans but is then used as the
   limit check for number of predicates. This is incorrect as it is now two
   higher than what is expected.
 
   Use a separate variable for the size of the predicate array.
 
 - Fix the filter operator stack check
 
   The operator stack increments the pointer and then writes the content onto
   the stack. The check for overflow compared the current pointer to see if
   it was greater than the stack size before doing so. This is an off by 2
   error as the write will be at the size - 1 and the compare is done before
   the increment. Adjust the check accordingly.
 -----BEGIN PGP SIGNATURE-----
 
 iIoEABYKADIWIQRRSw7ePDh/lE+zeZMp5XQQmuv6qgUCatItoRQccm9zdGVkdEBn
 b29kbWlzLm9yZwAKCRAp5XQQmuv6qmfsAP9XviDyrl49/PBpuanB2qQzlMGqYQlb
 CwISmzgWoO1jKQEArNiSpKsIdPLfSJSLfIHAGxAZfmT42SugA4M5jqhW3Qc=
 =7KiP
 -----END PGP SIGNATURE-----

Merge tag 'trace-v7.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull tracing fixes from Steven Rostedt:

 - Fix NULL dereference when copying histogram field variable

   If event_hist_trigger_parse() creates an action that uses one of
   pseudo fields for its keys, the hist_data field element will have a
   NULL for its field member. When looking to match that key, the lookup
   uses key_field->field->name which will dereference a NULL pointer.
   Instead use the helper function that handles such cases:
   expr_field_str().

 - Take the trace_types_lock when dropping the buffer_meta reference

   The tracing_buffer_meta_open() error return drops the trace_array
   reference with __trace_array_put() instead of trace_array_put() where
   the former doesn't take the lock and the latter does.

 - Fix NULL pointer dereference when reading per_cpu/cpuN/buffer_meta

   These files are created for every possible CPU. But it only contains
   data for CPUs that have come online. If one is read for a CPU that
   hasn't come online yet, it triggers a NULL pointer dereference.

   Have reading of CPUs that have not come on line yet return -ENODEV.

 - Fix an out-of-bounds shift in the log2 histogram modifier

   Histograms can take a log2 modifier to have the buckets defined by
   log2 increments. If a shift is greater than ULONG_MAX or above 2^63,
   the key falls into a lower order bucket.

   Use order_base_2() instead of "ilog2(n - 1) + 1" to have all
   overflowed keys go into the top bucket.

 - Fix the persistent ring buffer rb_meta_subbuf_idx() accounting

   The algorithm for finding the index of a sub-buffer in a persistent
   ring buffer buffer did not take into account the meta data at the
   beginning of the buffer causing the wrong index to be returned.

   As rb_subbufs_from_meta() does the proper accounting to find the
   first sub-buffer, use that function instead of repeating the logic
   (incorrectly) and make the calculations based off of that.

 - Fix the symbol name checks for the remote buffer code

   The remote ring buffer has a build time check to make sure its not
   using any code that will not be in the hypervisor. For various
   architectures, there has been false positive reports from this
   checker.

   Fix them.

 - Fix false warning in ring_buffer_map_get_reader()

   There is a WARN_ON() after rb_get_reader_page() if no reader is
   returned. But there are legitimate cases where this can happen.
   Remove the WARN_ON() and also a check that covers one of the
   legitimate cases that tries to exit out early. There's no need for
   the check if it just simply allows the return of NULL from
   rb_get_reader_page().

 - Fix the ignored return value from resize_buffer_duplicate_size()

   Some clean up of the code in tracing_snapshot_write() removed
   checking the return value of resize_buffer_duplicate_size() and if
   that failed it would not be detected.

 - Fix the histogram timestamps for buffered events

   The histogram timestamps are taken from the events that are recorded.
   It currently reads ring_buffer_event_time_stamp() but if the event is
   buffered it does not read it properly. Use tracing_event_time_stamp()
   which handles both buffered and normal events.

 - Do not initialize tracefs if tracing is disabled at boot

   If tracing fails to allocate or some other error is detected,
   tracing_disabled is set. Do not initialize tracefs in this case as it
   may expect data to be initialized but is not.

 - Free eventfs inode after an RCU grace period

   Currently eventfs_inodes are freed after a SRCU grace period as the
   iterations in the code use SRCU. There are locations that the inode
   may still be accessed from the VFS that uses RCU which does not have
   the same synchronization as SRCU. Add an RCU wait before free eventfs
   inodes.

 - Do not fail persistent and remote buffers under memory pressure

   As persistent and remote buffers have their own pre-allocated memory,
   there's no reason to check how much memory is available before
   created them. By checking the memory pressure, these buffers may fail
   to be created even though their memory is already present.

 - Account for subbuffer size when checking how much memory is available

   Before allocating a ring buffer, the size is checked against the
   current memory pressure of the system. But it assumes every
   sub-buffer is of page size. This is no longer the case. Use the
   actual sub-buffer size when calculating how much memory will be used.

 - Reject non-stack fields for synthetic stacktrace fields

   Stack traces are special fields and the checks currently do not do
   enough to make sure that the fields being processed as stack traces
   are indeed stack traces. Update the logic to properly detect what is
   or is not a stack trace.

 - Fix a crash in print_graph_function_event()

   When a tracer does not define static or default flags the
   tr->current_trace_flags is set to NULL. If the ring buffer is not
   cleared when switching tracers, the previous tracers events could be
   read. The function_graph entries will dereference the
   tr->current_trace_flags and cause a crash.

   Set the tr->current_trace_flags to a empty set of flags to prevent it
   from being NULL.

 - Separate tracing filter predicate count from allocation

   The amount allocated for the predicate program is the number of
   predicates defined plus two for adding "true" and "false" at the end.
   The nr_preds is incremented by two to accommodate the booleans but is
   then used as the limit check for number of predicates. This is
   incorrect as it is now two higher than what is expected.

   Use a separate variable for the size of the predicate array.

 - Fix the filter operator stack check

   The operator stack increments the pointer and then writes the content
   onto the stack. The check for overflow compared the current pointer
   to see if it was greater than the stack size before doing so. This is
   an off by 2 error as the write will be at the size - 1 and the
   compare is done before the increment. Adjust the check accordingly.

* tag 'trace-v7.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  tracing: Check operator stack capacity before pushing
  tracing: Keep the predicate limit separate from program capacity
  tracing: Fix crash in print_graph_function_event()
  tracing/histograms: Reject non-stacktrace fields for synthetic stacktrace fields
  ring-buffer: Use subbuf_order in available memory estimation
  ring-buffer: Skip si_mem_available() for persistent and remote buffers
  eventfs: Free the eventfs_inode after an rcu grace period too
  tracing: Do not initialize tracefs work if tracing is disabled
  tracing: Fix hist trigger timestamps for buffered events
  tracing: Fix ignored return value of resize_buffer_duplicate_size()
  ring-buffer: Fix false warning in ring_buffer_map_get_reader()
  tracing: Fix simple_ring_buffer undef check on sparc64
  tracing: Fix simple_ring_buffer undef check on parisc
  tracing: Fix empty symbol names in simple_ring_buffer undef check
  ring-buffer: Fix the sub-buffer array base in rb_meta_subbuf_idx()
  tracing: Fix the shift out of bounds in the log2 histogram modifier
  ring-buffer: Do not show buffer_meta for CPUs without a buffer
  tracing: Take trace_types_lock when dropping the buffer_meta reference
  tracing: Fix NULL dereference when copying keys for a field variable
2026-10-16 14:27:22 -10:00
..
rv rv: Fix 32-bit build of nomiss KUnit test 2026-08-04 16:11:27 +02:00
blktrace.c block-7.0-20260305 2026-03-06 08:36:18 -08:00
bpf_trace.c bpf: Make bpf_trampoline_multi_detach return void 2026-08-13 02:52:23 +02:00
bpf_trace.h
error_report-traces.c
fgraph.c fgraph: Remove unused FGRAPH_MAX_INDEX 2026-09-11 13:37:50 -04:00
fprobe.c fprobe: Use guard(rcu_sched_notrace) and check rcu_is_watching() 2026-09-30 08:41:31 +09:00
ftrace_internal.h
ftrace.c ftrace: Use rcu_assign_pointer() for tmp_ops filter hash 2026-09-12 13:27:29 -04:00
Kconfig tracing/probes: Support dumping fetcharg program for debugging dynamic events 2026-07-02 21:12:40 +09:00
kprobe_event_gen_test.c
Makefile tracing: Fix simple_ring_buffer undef check on sparc64 2026-10-14 19:03:39 -04:00
pid_list.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
pid_list.h trace/pid_list: optimize pid_list->lock contention 2025-11-13 15:15:54 -05:00
power-traces.c PM: cpufreq: powernv/tracing: Move powernv_throttle trace event 2025-07-21 16:40:56 -04:00
preemptirq_delay_test.c tracing: Reject invalid preemptirq_delay_test CPU affinity 2026-07-28 07:18:50 -04:00
remote_test_events.h tracing: Add a trace remote module for testing 2026-03-09 12:33:55 -04:00
remote_test.c tracing: Fix desc in error path for the trace remote test module 2026-05-16 16:11:04 -04:00
rethook.c tracing: Fix typo "availabe" in comment 2026-09-11 13:54:14 -04:00
ring_buffer_benchmark.c tracing: Fix subbuf resize races with trace_pipe_raw readers 2026-09-04 16:19:07 -04:00
ring_buffer.c ring-buffer: Use subbuf_order in available memory estimation 2026-10-15 08:52:26 -04:00
rpm-traces.c
simple_ring_buffer.c tracing: Fix retry exhaustion in simple ring buffer reader swap 2026-08-27 21:31:41 -04:00
synth_event_gen_test.c
trace_benchmark.c
trace_benchmark.h
trace_boot.c tracing/boot: Add support for eprobe, fprobe, and tprobe events 2026-08-08 21:20:55 +09:00
trace_branch.c tracing/branch: Use pr_warn() instead of printk(KERN_WARNING) 2026-05-21 18:03:08 -04:00
trace_btf.c tracing/probes: Fix BTF kflag check for anonymous struct member access 2026-09-03 09:04:25 +09:00
trace_btf.h tracing/probes: Fix BTF kflag check for anonymous struct member access 2026-09-03 09:04:25 +09:00
trace_clock.c
trace_dynevent.c tracing/boot: Add support for eprobe, fprobe, and tprobe events 2026-08-08 21:20:55 +09:00
trace_dynevent.h
trace_entries.h tracing: Fix ftrace event field alignments 2026-02-05 09:47:11 -05:00
trace_eprobe.c treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
trace_event_perf.c perf/ftrace: Fix WARNING in __unregister_ftrace_function 2026-05-29 11:27:40 -04:00
trace_events_filter_test.h
trace_events_filter.c tracing: Check operator stack capacity before pushing 2026-10-15 18:07:15 -04:00
trace_events_hist.c tracing/histograms: Reject non-stacktrace fields for synthetic stacktrace fields 2026-10-15 08:52:44 -04:00
trace_events_inject.c
trace_events_synth.c tracing/synthetic: Free type string on error path 2026-07-07 13:59:55 -04:00
trace_events_trigger.c tracing: Don't dereference trace_event_file in deferred trigger free 2026-09-12 13:27:41 -04:00
trace_events_user.c tracing/user_events: Don't destroy fields when event removal fails 2026-09-11 13:30:15 -04:00
trace_events.c tracing: Restore :mod: trailer after parsing in ftrace_set_clr_event() 2026-09-11 14:01:46 -04:00
trace_export.c tracing: Fix ftrace event field alignments 2026-02-05 09:47:11 -05:00
trace_fprobe.c Probes updates for v7.3: 2026-08-20 15:11:52 -07:00
trace_functions_graph.c function_graph: Use the saved entry's size when reprinting it 2026-09-11 13:39:08 -04:00
trace_functions.c ftrace: Take trace_array reference before accessing its ftrace_ops 2026-09-01 16:38:19 -04:00
trace_hwlat.c tracing: Fix false sharing in hwlat get_sample() 2026-02-10 03:36:39 -05:00
trace_irqsoff.c tracing: Allow tracer to add more than 32 options 2025-11-04 21:44:00 +09:00
trace_kdb.c tracing: Allow tracer to add more than 32 options 2025-11-04 21:44:00 +09:00
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_kprobe.c tracing/probes: Treating longer symbol name on event comparation 2026-07-28 23:55:35 +09:00
trace_mmiotrace.c tracing updates for v7.3: 2026-08-19 14:06:14 -07:00
trace_nop.c
trace_osnoise.c tracing/osnoise: Call synchronize_rcu() when unregistering 2026-07-06 14:56:18 -04:00
trace_output.c tracing updates for v7.1: 2026-04-17 09:43:12 -07:00
trace_output.h tracing: Allow tracer to add more than 32 options 2025-11-04 21:44:00 +09:00
trace_pid.c tracing: Move pid filtering into trace_pid.c 2026-02-08 21:01:13 -05:00
trace_preemptirq.c tracing: Add a no-rcu-check version of trace_##event##_enabled() 2026-07-07 10:42:29 -04:00
trace_printk.c kernel/trace/trace_printk: Use kstrdup() instead of kmalloc() and strcpy() 2026-07-28 07:18:48 -04:00
trace_probe_kernel.h tracing/probes: Fix extra whitespace in trace_probe_kernel.h 2026-07-21 18:00:13 +09:00
trace_probe_tmpl.h tracing/probes: Add this_cpu_read() and this_cpu_ptr() dereference method to fetcharg 2026-07-14 22:43:16 +09:00
trace_probe.c tracing: probes: error if BTF is required but unavailable 2026-10-15 10:09:36 +09:00
trace_probe.h tracing/probes: Fix use-after-free on field name/type of events with multiple probes 2026-09-03 09:04:25 +09:00
trace_recursion_record.c tracing: Switch trace_recursion_record.c code over to use guard() 2026-05-21 18:03:07 -04:00
trace_remote.c tracing/remotes: Catch nr_page_va overflow in ring_buffer_desc sizing 2026-09-13 13:06:43 -04:00
trace_sched_switch.c tracing: Use strscpy() instead of strcpy() in trace_sched_switch 2026-07-28 07:18:50 -04:00
trace_sched_wakeup.c tracing: Allow tracer to add more than 32 options 2025-11-04 21:44:00 +09:00
trace_selftest_dynamic.c
trace_selftest.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
trace_seq.c tracing: Add bitmask-list option for human-readable bitmask display 2026-01-26 17:00:50 -05:00
trace_snapshot.c tracing: Fix ignored return value of resize_buffer_duplicate_size() 2026-10-14 19:03:40 -04:00
trace_stack.c ftrace: Take trace_array reference before accessing its ftrace_ops 2026-09-01 16:38:19 -04:00
trace_stat.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
trace_stat.h
trace_synth.h
trace_syscalls.c tracing: Make per-template BTF id lists file-local 2026-08-05 22:02:29 -04:00
trace_uprobe.c uprobes: guard trace cleanup against error pointers 2026-09-01 09:50:11 +09:00
trace.c tracing: Fix crash in print_graph_function_event() 2026-10-15 18:03:48 -04:00
trace.h tracing: Don't dereference trace_event_file in deferred trigger free 2026-09-12 13:27:41 -04:00
tracing_map.c tracing: Simplify pages allocation for tracing_map logic 2026-05-21 18:12:10 -04:00
tracing_map.h tracing: Simplify pages allocation for tracing_map logic 2026-05-21 18:12:10 -04:00
undefsyms_base.c tracing: Fix simple_ring_buffer undef check on parisc 2026-10-14 19:03:39 -04:00