linux/kernel
Linus Torvalds 864be1277d tracing fix for 7.2:
- Move rb_desc->nr_page_va before updating dynamic array
 
   The rb_descr->page_va is a dynamic array counted by nr_page_va. But the
   updating of the page_va[] is done before the nr_page_va is incremented
   causing a build with CONFIG_UBSAN_BOUNDS to flag it as an overflow.
 
   Move the increment of the counted by value before the array element is
   updated.
 
 - Propagate errors from remote event bulk updates
 
   The return value of trace_remote_enable_event() was not being checked by
   remote_events_dir_enable_write() where it would silently fail. Have it
   check the return value and propagate that back up to user space.
 
 - Fix resource leak on mmiotrace trace_pipe close
 
   The mmiotrace tracer was created in 2008 before the trace_pipe had a close
   callback to allow tracers to do clean up from trace_pipe open. The
   trace_pipe close cleanup callback was added in 2009 but the mmiotrace
   tracer was not updated. It had a hack to do the cleanup in the read call,
   where it may leak if user space did not read the entire buffer.
 
   Add a callback to mmiotrace trace_pipe close do to the cleanup properly.
 
 - Fix a possible NULL pointer dereference in the mmiotrace tracer
 
   If the mmio_pipe_open() fails to find a PCI device, it will set the
   hiter->dev pointer to NULL. The read function will blindly dereference
   that pointer. Fix the read call to check to see if that pointer is
   populated before dereferencing it.
 
 - Fix union collision of module and refcnt for dynamic events
 
   In 'struct trace_event_call', the 'module' pointer and the 'refcnt' atomic
   variable share the same memory space in a union. The filter on module
   logic only checked if the 'module' was set to determine if the event
   belonged to the module. As dynamic events are always builtin, it doesn't
   need the 'module' field of the structure and used a refcount. But the
   module filtering logic would then mistaken these dynamic events as a
   module and call module_name(event->module) on it.
 
   Add a check to see if the event is a dynamic event and if so, do not check
   it for being part of the given module.
 
 - Reset the top level buffer in selftests before running instances
 
   The ftracetest selftest initializes each instance before executing the
   tests. But it does not reset the top level buffer. Dynamic events are only
   added and removed by the top level so any left over dynamic events will
   not be removed by the reset in the instances.
 
   Left over dynamic events can cause the tests to incorrectly fail. Reset
   the top level buffer before running the instances.
 
 - Make the context_switch counter 64 bit
 
   The code to read user space for a system call trace event or for a
   trace_marker will disable migration, enable preemption, read user space
   into a per CPU buffer, disable preemption and enable migration again.
   It checks if the per CPU context switch counter to see if it changed, and
   if it did not, it would know that the per CPU buffer was not touched by
   another task.
 
   But the save counter was 32 bit and it would compare it to the 64 bit
   context_switch variable. A long running system could have the
   context_switch variable greater that 1<<32 in which case the compare will
   always fail. The compare will promote the 32 bit int saved value to 64 bit
   and compare it to the full 64 bit counter. Since the top 32 bits of the
   saved value was zero, it would never match.
 
 - Fix a use-after-free of the event_enable trigger
 
   The event_enable trigger allows for enabling one event when another event
   is triggered. When the trigger is removed, it must go through a
   synchronization phase to make sure it is not triggered again. The trigger
   itself is delayed by the "bulk delay" logic that was recently added.
   But the code that frees the event_enable data used to rely on the trigger
   code to do the synchronization. Now that the code uses the call RCU
   functions (and a workqueue), that delay no longer is there.
 
   Add a callback private_data_free() function that allows triggers to clean
   up data after the synchronization phase has completed.
 
 - Move the module_ref counter into the delay callback
 
   Since an event of the event_enable trigger can enable an event for a
   module, it ups the module ref count for that event's module. This prevents
   the event from trying to enable an event that no longer exists and cause a
   use-after-free bug.
 
   The ref counter was set back down when the trigger was removed but not
   after thy synchronization phase. This could lead to the module data being
   accessed after module was unloaded.
 
   Move the module ref decrement into the private_data_free() callback of the
   event_enable trigger.
 
 - Add mutex to protect parser in ftrace filtering
 
   The set_ftrace_filter file uses a parsing descriptor that is allocated at
   open and modified by writes. If multiple threads were to write to the
   descriptor at the same time, it can corrupt the parser.
 
   Add a mutex around the modifications of the parser descriptor.
 
 - Fix possible corruption in perf syscall tracing
 
   The perf system call trace events can now read user space. To do so, the
   reads of user space enable preemption and disables it again. During this
   time that preemption is enabled, the task can migrate. The perf event list
   head is assigned via a per CPU pointer. It is done before the user space
   part is called. If the user space reading migrates the task to another
   CPU, then the head pointer is no longer valid.
 
   Re-assign the head pointer after the reading of user space to keep it
   using the correct data.
 -----BEGIN PGP SIGNATURE-----
 
 iIoEABYKADIWIQRRSw7ePDh/lE+zeZMp5XQQmuv6qgUCamYDGhQccm9zdGVkdEBn
 b29kbWlzLm9yZwAKCRAp5XQQmuv6qkhYAP9G5wDTVQQzitl900iWp9rvQ2Qm5UWN
 JDnK2HO1elmj0AD8CRiHBI5W3O2yUmoO4bOFZ9YFXz+DqJ1jwkDs5FfqjAU=
 =EMD9
 -----END PGP SIGNATURE-----

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

Pull tracing fixes from Steven Rostedt:

 - Move rb_desc->nr_page_va before updating dynamic array

   The rb_descr->page_va is a dynamic array counted by nr_page_va. But
   the updating of the page_va[] is done before the nr_page_va is
   incremented causing a build with CONFIG_UBSAN_BOUNDS to flag it as an
   overflow.

   Move the increment of the counted by value before the array element
   is updated.

 - Propagate errors from remote event bulk updates

   The return value of trace_remote_enable_event() was not being checked
   by remote_events_dir_enable_write() where it would silently fail.
   Have it check the return value and propagate that back up to user
   space.

 - Fix resource leak on mmiotrace trace_pipe close

   The mmiotrace tracer was created in 2008 before the trace_pipe had a
   close callback to allow tracers to do clean up from trace_pipe open.
   The trace_pipe close cleanup callback was added in 2009 but the
   mmiotrace tracer was not updated. It had a hack to do the cleanup in
   the read call, where it may leak if user space did not read the
   entire buffer.

   Add a callback to mmiotrace trace_pipe close do to the cleanup
   properly.

 - Fix a possible NULL pointer dereference in the mmiotrace tracer

   If the mmio_pipe_open() fails to find a PCI device, it will set the
   hiter->dev pointer to NULL. The read function will blindly
   dereference that pointer. Fix the read call to check to see if that
   pointer is populated before dereferencing it.

 - Fix union collision of module and refcnt for dynamic events

   In 'struct trace_event_call', the 'module' pointer and the 'refcnt'
   atomic variable share the same memory space in a union. The filter on
   module logic only checked if the 'module' was set to determine if the
   event belonged to the module. As dynamic events are always builtin,
   it doesn't need the 'module' field of the structure and used a
   refcount. But the module filtering logic would then mistaken these
   dynamic events as a module and call module_name(event->module) on it.

   Add a check to see if the event is a dynamic event and if so, do not
   check it for being part of the given module.

 - Reset the top level buffer in selftests before running instances

   The ftracetest selftest initializes each instance before executing
   the tests. But it does not reset the top level buffer. Dynamic events
   are only added and removed by the top level so any left over dynamic
   events will not be removed by the reset in the instances.

   Left over dynamic events can cause the tests to incorrectly fail.
   Reset the top level buffer before running the instances.

 - Make the context_switch counter 64 bit

   The code to read user space for a system call trace event or for a
   trace_marker will disable migration, enable preemption, read user
   space into a per CPU buffer, disable preemption and enable migration
   again. It checks if the per CPU context switch counter to see if it
   changed, and if it did not, it would know that the per CPU buffer was
   not touched by another task.

   But the save counter was 32 bit and it would compare it to the 64 bit
   context_switch variable. A long running system could have the
   context_switch variable greater that 1<<32 in which case the compare
   will always fail. The compare will promote the 32 bit int saved value
   to 64 bit and compare it to the full 64 bit counter. Since the top 32
   bits of the saved value was zero, it would never match.

 - Fix a use-after-free of the event_enable trigger

   The event_enable trigger allows for enabling one event when another
   event is triggered. When the trigger is removed, it must go through a
   synchronization phase to make sure it is not triggered again. The
   trigger itself is delayed by the "bulk delay" logic that was recently
   added. But the code that frees the event_enable data used to rely on
   the trigger code to do the synchronization. Now that the code uses
   the call RCU functions (and a workqueue), that delay no longer is
   there.

   Add a callback private_data_free() function that allows triggers to
   clean up data after the synchronization phase has completed.

 - Move the module_ref counter into the delay callback

   Since an event of the event_enable trigger can enable an event for a
   module, it ups the module ref count for that event's module. This
   prevents the event from trying to enable an event that no longer
   exists and cause a use-after-free bug.

   The ref counter was set back down when the trigger was removed but
   not after thy synchronization phase. This could lead to the module
   data being accessed after module was unloaded.

   Move the module ref decrement into the private_data_free() callback
   of the event_enable trigger.

 - Add mutex to protect parser in ftrace filtering

   The set_ftrace_filter file uses a parsing descriptor that is
   allocated at open and modified by writes. If multiple threads were to
   write to the descriptor at the same time, it can corrupt the parser.

   Add a mutex around the modifications of the parser descriptor.

 - Fix possible corruption in perf syscall tracing

   The perf system call trace events can now read user space. To do so,
   the reads of user space enable preemption and disables it again.
   During this time that preemption is enabled, the task can migrate.
   The perf event list head is assigned via a per CPU pointer. It is
   done before the user space part is called. If the user space reading
   migrates the task to another CPU, then the head pointer is no longer
   valid.

   Re-assign the head pointer after the reading of user space to keep it
   using the correct data.

* tag 'trace-v7.2-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  tracing: perf: Fix stale head for perf syscall tracing
  ftrace: Add global mutex to serialize trace_parser access
  tracing: Delay module ref count for "enable_event" trigger
  tracing: Fix use-after-free freeing trigger private data
  tracing: Fix context switch counter truncation
  selftests/ftrace: Reset triggers at top level before instance loop
  tracing: Fix union collision of module and refcnt for dynamic events
  tracing: Fix mmiotrace possible NULL dereferencing of hiter->dev
  tracing: Fix resource leak on mmiotrace trace_pipe close
  tracing: Propagate errors from remote event bulk updates
  tracing/remotes: Fix page_va[] access before counter update in trace_remote_alloc_buffer()
2026-07-26 09:15:59 -07:00
..
bpf bpf: Reject passing scalar NULL to nonnull arg of a global subprog 2026-07-23 16:09:07 -07:00
cgroup cgroup/cpuset: rebind mm mempolicy to effective_mems, not mems_allowed 2026-07-06 12:05:02 -10:00
configs slab: support for compiler-assisted type-based slab cache partitioning 2026-05-14 10:44:09 +02:00
debug kgdb: update outdated references to kgdb_wait() 2026-04-21 16:41:54 +01:00
dma dma-mapping updates for Linux 7.2: 2026-06-17 12:20:21 -07:00
entry futex: Provide infrastructure to plug the non contended robust futex unlock race 2026-06-03 11:38:52 +02:00
events perf/aux: Fix page UAF in map_range() 2026-07-10 12:12:24 +02:00
futex futex/requeue: Revert "Prevent NULL pointer dereference in remove_waiter() on self-deadlock"" 2026-07-02 22:14:08 +02:00
gcov Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
irq genirq/msi: Correct CONFIG_PCI_MSI_ARCH_FALLBACKS macro name in comment 2026-06-22 22:32:01 +02:00
kcsan kcsan: test: Adjust "expect" allocation type for kmalloc_obj 2026-02-26 09:54:08 -08:00
livepatch Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
liveupdate liveupdate: fix GET_NAME ioctl argument validation 2026-07-16 09:25:30 +03:00
locking locking/rt: Fix the incorrect RCU protection in rt_spin_unlock() 2026-06-21 11:51:13 +02:00
module module: decompress: check return value of module_extend_max_pages() 2026-06-04 16:37:32 +00:00
power mm.git review status for mm-hotfixes-stable..mm-stable 2026-06-19 10:14:34 -07:00
printk printk: fix typos in comments 2026-06-02 15:36:06 +02:00
rcu Updates for the NOHZ subsystem: 2026-06-15 13:48:52 +05:30
sched sched_ext: Fixes for v7.2-rc3 2026-07-13 15:55:17 -07:00
time posix-cpu-timers: Prevent UAF caused by non-leader exec() race 2026-07-05 11:44:06 +02:00
trace tracing fix for 7.2: 2026-07-26 09:15:59 -07:00
unwind Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
.gitignore
acct.c fs: move SB_I_USERNS_VISIBLE to FS_USERNS_MOUNT_RESTRICTED 2026-05-11 23:13:01 +02:00
async.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
audit_fsnotify.c audit: fix recursive locking deadlock in audit_dupe_exe() 2026-05-27 19:15:34 -04:00
audit_tree.c audit: use 'unsigned int' instead of 'unsigned' 2026-05-26 17:15:30 -04:00
audit_watch.c audit: fix recursive locking deadlock in audit_dupe_exe() 2026-05-27 19:15:34 -04:00
audit.c audit: fix potential integer overflow in audit_log_n_hex() 2026-07-08 14:22:14 -04:00
audit.h audit: fix recursive locking deadlock in audit_dupe_exe() 2026-05-27 19:15:34 -04:00
auditfilter.c audit: fix recursive locking deadlock in audit_dupe_exe() 2026-05-27 19:15:34 -04:00
auditsc.c audit/stable-7.2 PR 20260615 2026-06-17 12:55:09 +01:00
backtracetest.c
bounds.c x86/asm: Remove ANNOTATE_DATA_SPECIAL usage 2025-12-03 16:53:19 +01:00
capability.c
cfi.c
compat.c
configs.c
context_tracking.c context_tracking: Remove rcu_task_trace_heavyweight_{enter,exit}() 2026-01-01 16:39:46 +08:00
cpu_pm.c
cpu.c Misc CPU hotplug fixes: 2026-06-23 16:43:24 -07:00
crash_core_test.c
crash_core.c kernel/crash: remove inclusion of crypto/sha1.h 2026-03-27 21:19:46 -07:00
crash_dump_dm_crypt.c crash_dump/dm-crypt: don't print in arch-specific code 2026-04-02 23:36:24 -07:00
crash_reserve.c kernel/crash: remove inclusion of crypto/sha1.h 2026-03-27 21:19:46 -07:00
cred.c exec_state: relocate dumpable information 2026-05-26 11:02:01 +02:00
delayacct.c delayacct: fix uapi timespec64 definition 2026-02-08 00:13:32 -08:00
dma.c
elfcorehdr.c
exec_domain.c
exec_state.c exec_state: relocate dumpable information 2026-05-26 11:02:01 +02:00
exit.c posix-cpu-timers: Prevent UAF caused by non-leader exec() race 2026-07-05 11:44:06 +02:00
exit.h
extable.c
fail_function.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
fork.c bpf,fork: wipe ->bpf_storage before bailouts that access it 2026-06-29 15:08:23 -07:00
freezer.c
gen_kheaders.sh
groups.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
hung_task.c hung_task: explicitly report I/O wait state in log output 2026-03-27 21:19:40 -07:00
iomem.c
irq_work.c irq_work: Fix use-after-free in irq_work_single() on PREEMPT_RT 2026-05-11 16:28:04 +02:00
jump_label.c jump_label: use ATOMIC_INIT() for initialization of .enabled 2026-03-16 13:16:48 +01:00
kallsyms_internal.h kallsyms: Get rid of kallsyms relative base 2026-01-22 15:58:22 -07:00
kallsyms_selftest.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kallsyms_selftest.h
kallsyms.c mm.git review status for linus..mm-nonmm-stable 2026-02-12 12:13:01 -08:00
kcmp.c
Kconfig.freezer
Kconfig.hz
Kconfig.kexec
Kconfig.locks
Kconfig.preempt sched: Further restrict the preemption modes 2026-01-08 12:43:57 +01:00
kcov.c kcov: use WRITE_ONCE() for selftest mode stores 2026-06-04 14:49:26 -07:00
kexec_core.c liveupdate: skip serialization for context-preserving kexec 2026-06-01 09:19:38 +03:00
kexec_elf.c
kexec_file.c kexec: derive purgatory entry from symbol 2026-01-31 16:16:07 -08:00
kexec_internal.h
kexec.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kheaders.c
kprobes.c kprobes: Remove unneeded warnings from __arm_kprobe_ftrace() 2026-03-13 23:15:26 +09:00
kstack_erase.c
ksyms_common.c
ksysfs.c kernel: ksysfs: initialize kernel_kobj earlier 2026-04-03 19:39:52 +02:00
kthread.c exec_state: relocate dumpable information 2026-05-26 11:02:01 +02:00
latencytop.c
Makefile exec: introduce struct task_exec_state 2026-05-26 11:02:01 +02:00
module_signature.c module: Give 'enum pkey_id_type' a more specific name 2026-03-24 21:42:37 +00:00
notifier.c
nscommon.c nsfs: tighten permission checks for ns iteration ioctls 2026-02-27 22:00:08 +01:00
nsproxy.c vfs-7.1-rc1.mount.v2 2026-04-14 19:59:25 -07:00
nstree.c nstree: tighten permission checks for listing 2026-02-27 22:00:11 +01:00
padata.c padata: Put CPU offline callback in ONLINE section to allow failure 2026-03-22 11:17:59 +09:00
panic.c bug/kunit: Core support for suppressing warning backtraces 2026-05-14 10:50:00 -06:00
params.c kernel: param: initialize module_kset in a pure_initcall 2026-06-08 23:27:56 +02:00
pid_namespace.c pid_namespace: allow opening pid_for_children before init was created 2026-03-20 14:44:26 +01:00
pid_sysctl.h
pid.c pidfd: refuse access to tasks that have started exiting harder 2026-05-19 08:57:47 +02:00
profile.c
ptrace.c exec_state: relocate dumpable information 2026-05-26 11:02:01 +02:00
range.c
reboot.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
regset.c
relay.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
resource_kunit.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
resource.c resource: Make resource_alignment() input const resource 2026-06-23 12:08:51 -05:00
rseq.c rseq: Reenable performance optimizations conditionally 2026-05-06 17:40:27 +02:00
scftorture.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
scs.c
seccomp.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
signal.c posix-cpu-timers: Prevent UAF caused by non-leader exec() race 2026-07-05 11:44:06 +02:00
smp.c smp: Make CSD lock acquisition atomic for debug mode 2026-07-22 20:57:08 +02:00
smpboot.c
smpboot.h
softirq.c softirq: Prepare for deferred hrtimer rearming 2026-02-27 16:40:13 +01:00
stacktrace.c
static_call_inline.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
static_call.c
stop_machine.c sched: Simplify ifdeffery around cpu_smt_mask 2026-05-19 12:17:37 +02:00
sys_ni.c rseq: Implement sys_rseq_slice_yield() 2026-01-22 11:11:17 +01:00
sys.c exec_state: relocate dumpable information 2026-05-26 11:02:01 +02:00
sysctl-test.c
sysctl.c sysctl: fix uninitialized variable in proc_do_large_bitmap 2026-03-26 09:32:19 +01:00
task_work.c
taskstats.c taskstats: retain dead thread stats in TGID queries 2026-05-28 21:24:41 -07:00
torture.c torture: Add torture_sched_set_normal() for user-specified nice values 2026-05-24 09:38:47 +02:00
tracepoint.c tracepoint: balance regfunc() on func_add() failure in tracepoint_add_func() 2026-04-14 05:17:02 -04:00
tsacct.c tsacct: skip all kernel threads 2026-01-26 19:07:13 -08:00
ucount.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
uid16.c
uid16.h
umh.c umh: replace use of system_unbound_wq with system_dfl_wq 2026-05-07 11:30:08 -10:00
up.c
user_namespace.c Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses 2026-02-22 08:26:33 -08:00
user-return-notifier.c
user.c
utsname_sysctl.c
utsname.c
vhost_task.c vhost_task_create: kill unnecessary .exit_signal initialization 2026-06-10 02:17:00 -04:00
vmcore_info.c mm.git review status for linus..mm-nonmm-stable 2026-04-16 20:11:56 -07:00
watch_queue.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
watchdog_buddy.c watchdog/hardlockup: improve buddy system detection timeliness 2026-03-27 21:19:47 -07:00
watchdog_perf.c watchdog/hardlockup: simplify perf event probe and remove per-cpu dependency 2026-02-08 00:13:35 -08:00
watchdog.c watchdog/hardlockup: improve buddy system detection timeliness 2026-03-27 21:19:47 -07:00
workqueue_internal.h workqueue: Show in-flight work item duration in stall diagnostics 2026-03-05 07:27:48 -10:00
workqueue.c workqueue: Changes for v7.2 2026-06-17 11:57:44 +01:00