[tip: core/entry] entry: Make return type of syscall_trace_enter() bool

tip-bot2 for Thomas Gleixner posted 1 patch 4 days, 6 hours ago
include/linux/entry-common.h | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
[tip: core/entry] entry: Make return type of syscall_trace_enter() bool
Posted by tip-bot2 for Thomas Gleixner 4 days, 6 hours ago
The following commit has been merged into the core/entry branch of tip:

Commit-ID:     71ff30013f19ca46c2c72c25731c32b6cc7b5620
Gitweb:        https://git.kernel.org/tip/71ff30013f19ca46c2c72c25731c32b6cc7b5620
Author:        Thomas Gleixner <tglx@kernel.org>
AuthorDate:    Sun, 12 Jul 2026 23:25:27 +02:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Mon, 20 Jul 2026 20:38:40 +02:00

entry: Make return type of syscall_trace_enter() bool

This prepares for changing the return types of
syscall_enter_from_user_mode[_work]() to bool, which in turn separates the
decision of invoking the syscall from the syscall number, which might have
been changed in the call by ptrace, seccomp, tracing.

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.699072205@kernel.org
---
 include/linux/entry-common.h | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index 38d1484..df221d9 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -72,7 +72,7 @@ static __always_inline long syscall_trace_enter(struct pt_regs *regs, unsigned l
 	 */
 	if (work & SYSCALL_WORK_SYSCALL_USER_DISPATCH) {
 		if (syscall_user_dispatch(regs))
-			return -1L;
+			return false;
 	}
 
 	/*
@@ -87,7 +87,7 @@ static __always_inline long syscall_trace_enter(struct pt_regs *regs, unsigned l
 	if (work & (SYSCALL_WORK_SYSCALL_TRACE | SYSCALL_WORK_SYSCALL_EMU)) {
 		if (!arch_ptrace_report_syscall_permit_entry(regs) ||
 		    (work & SYSCALL_WORK_SYSCALL_EMU))
-			return -1L;
+			return false;
 
 		/* ptrace might have changed work flags */
 		work = READ_ONCE(current_thread_info()->syscall_work);
@@ -96,7 +96,7 @@ static __always_inline long syscall_trace_enter(struct pt_regs *regs, unsigned l
 	/* Do seccomp after ptrace, to catch any tracer changes. */
 	if (work & SYSCALL_WORK_SECCOMP) {
 		if (!__seccomp_permit_syscall())
-			return -1L;
+			return false;
 	}
 
 	if (unlikely(work & SYSCALL_WORK_SYSCALL_TRACEPOINT))
@@ -105,8 +105,7 @@ static __always_inline long syscall_trace_enter(struct pt_regs *regs, unsigned l
 	if (unlikely(audit_context()))
 		syscall_enter_audit(regs);
 
-	/* Either of the above might have changed the syscall number */
-	return syscall_get_nr(current, regs);
+	return true;
 }
 
 /**
@@ -136,8 +135,13 @@ static __always_inline long syscall_enter_from_user_mode_work(struct pt_regs *re
 {
 	unsigned long work = READ_ONCE(current_thread_info()->syscall_work);
 
-	if (work & SYSCALL_WORK_ENTER)
-		syscall = syscall_trace_enter(regs, work, syscall);
+	if (work & SYSCALL_WORK_ENTER) {
+		if (!syscall_trace_enter(regs, work, syscall))
+			return -1L;
+
+		/* Reread the syscall number as it might have been modified */
+		syscall = syscall_get_nr(current, regs);
+	}
 
 	return syscall;
 }