tracing: perf: Fix stale head for perf syscall tracing
authorSteven Rostedt <rostedt@goodmis.org>
Fri, 24 Jul 2026 23:32:10 +0000 (19:32 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Sat, 25 Jul 2026 02:57:56 +0000 (22:57 -0400)
The code that can read the user space parameters of a system call may
enable preemption and migrate. The head of the per CPU perf events list
may be pointing to the wrong CPU event if the code migrates the task.

Reassign the head pointer if the system call event called the code that
may have caused a migration.

Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260724193210.03fae1d6@gandalf.local.home
Reported-by: Sashiko <>
Link: https://sashiko.dev/#/patchset/20260717173252.3431565-1-usama.arif%40linux.dev
Fixes: edca33a56297d ("tracing: Fix failure to read user space from system call trace events")
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_syscalls.c

index e98ee7e..8a4f3c7 100644 (file)
@@ -1451,6 +1451,11 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
                if (syscall_get_data(sys_data, args, &user_ptr,
                                     &size, user_sizes, &uargs, buf_size) < 0)
                        return;
+
+               /* The above may have caused a migration */
+               head = this_cpu_ptr(sys_data->enter_event->perf_events);
+               if (hlist_empty(head))
+                       return;
        }
 
        /* get the size after alignment with the u32 buffer size field */