[tip: core/entry] entry: Rework trace_syscall_enter()

tip-bot2 for Thomas Gleixner posted 1 patch 1 week, 4 days ago
There is a newer version of this series
include/linux/entry-common.h  | 10 ++++------
kernel/entry/syscall-common.c |  9 ++-------
2 files changed, 6 insertions(+), 13 deletions(-)
[tip: core/entry] entry: Rework trace_syscall_enter()
Posted by tip-bot2 for Thomas Gleixner 1 week, 4 days ago
The following commit has been merged into the core/entry branch of tip:

Commit-ID:     8bbaa0524675a8bd21b8aaed7538b6896d83b22c
Gitweb:        https://git.kernel.org/tip/8bbaa0524675a8bd21b8aaed7538b6896d83b22c
Author:        Thomas Gleixner <tglx@kernel.org>
AuthorDate:    Sun, 12 Jul 2026 23:25:22 +02:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 14 Jul 2026 16:57:16 +02:00

entry: Rework trace_syscall_enter()

Reread the syscall number from pt_regs and stop returning the eventually
modified syscall number.

That moves the reread to the end of syscall_trace_enter() and prepares for
moving it to the call site.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Tested-by: Michal Suchánek <msuchanek@suse.de>
Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
Link: https://patch.msgid.link/20260712141346.639115923@kernel.org
---
 include/linux/entry-common.h  | 10 ++++------
 kernel/entry/syscall-common.c |  9 ++-------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index 78cfeeb..38d1484 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -58,7 +58,7 @@ static __always_inline bool arch_ptrace_report_syscall_permit_entry(struct pt_re
 }
 #endif
 
-long trace_syscall_enter(struct pt_regs *regs, long syscall);
+void trace_syscall_enter(struct pt_regs *regs);
 void trace_syscall_exit(struct pt_regs *regs, long ret);
 void syscall_enter_audit(struct pt_regs *regs);
 
@@ -99,16 +99,14 @@ static __always_inline long syscall_trace_enter(struct pt_regs *regs, unsigned l
 			return -1L;
 	}
 
-	/* Either of the above might have changed the syscall number */
-	syscall = syscall_get_nr(current, regs);
-
 	if (unlikely(work & SYSCALL_WORK_SYSCALL_TRACEPOINT))
-		syscall = trace_syscall_enter(regs, syscall);
+		trace_syscall_enter(regs);
 
 	if (unlikely(audit_context()))
 		syscall_enter_audit(regs);
 
-	return syscall;
+	/* Either of the above might have changed the syscall number */
+	return syscall_get_nr(current, regs);
 }
 
 /**
diff --git a/kernel/entry/syscall-common.c b/kernel/entry/syscall-common.c
index b3cde6f..b8eac9e 100644
--- a/kernel/entry/syscall-common.c
+++ b/kernel/entry/syscall-common.c
@@ -8,14 +8,9 @@
 
 /* Out of line to prevent tracepoint code duplication */
 
-long trace_syscall_enter(struct pt_regs *regs, long syscall)
+void trace_syscall_enter(struct pt_regs *regs)
 {
-	trace_sys_enter(regs, syscall);
-	/*
-	 * Probes or BPF hooks in the tracepoint may have changed the
-	 * system call number. Reread it.
-	 */
-	return syscall_get_nr(current, regs);
+	trace_sys_enter(regs, syscall_get_nr(current, regs));
 }
 
 void trace_syscall_exit(struct pt_regs *regs, long ret)