Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 06 Aug 2026 23:21:39 +0000
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 387634c880be - stable/14 - kern: syscall_thread_enter() cannot fail
Message-ID:  <6a751703.251c5.5352c68c@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=387634c880bec9a24388529c7653b52ebea8f828

commit 387634c880bec9a24388529c7653b52ebea8f828
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2026-06-30 19:12:10 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2026-08-06 22:53:07 +0000

    kern: syscall_thread_enter() cannot fail
    
    Attempting to handle the error gracefully can easily result in missing
    SIGSYS, so this was made to always succeed in
    39024a89146 ("syscalls: fix missing SIGSYS for several ENOSYS errors")
    and returns the nosys entry on failure.
    
    Drop the pretense of returning an error and clean up a few dead error
    paths.
    
    Reviewed by:    kib, markj
    
    (cherry picked from commit eca26803d880060555393ab89b44b967cd467a0e)
---
 sys/kern/kern_sig.c      | 8 ++------
 sys/kern/kern_syscalls.c | 5 ++---
 sys/kern/subr_syscall.c  | 6 +-----
 sys/sys/sysent.h         | 2 +-
 4 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 88c93b98b646..cf71dfc89c3d 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -2703,7 +2703,7 @@ ptrace_syscallreq(struct thread *td, struct proc *p,
 	struct sysent *se;
 	register_t rv_saved[2];
 	unsigned int sc;
-	int error, nerror;
+	int nerror;
 	bool audited, sy_thr_static;
 
 	sc = tsr->ts_sa.code;
@@ -2747,12 +2747,8 @@ ptrace_syscallreq(struct thread *td, struct proc *p,
 	audited = AUDIT_SYSCALL_ENTER(sc, td) != 0;
 
 	if (!sy_thr_static) {
-		error = syscall_thread_enter(td, &se);
+		syscall_thread_enter(td, &se);
 		sy_thr_static = (se->sy_thrcnt & SY_THR_STATIC) != 0;
-		if (error != 0) {
-			tsr->ts_ret.sr_error = error;
-			return;
-		}
 	}
 
 	rv_saved[0] = td->td_retval[0];
diff --git a/sys/kern/kern_syscalls.c b/sys/kern/kern_syscalls.c
index 2dfe162f6c2e..1a5611d3986d 100644
--- a/sys/kern/kern_syscalls.c
+++ b/sys/kern/kern_syscalls.c
@@ -89,7 +89,7 @@ syscall_thread_drain(struct sysent *se)
 		pause("scdrn", hz/2);
 }
 
-int
+void
 syscall_thread_enter(struct thread *td, struct sysent **se)
 {
 	uint32_t cnt, oldcnt;
@@ -101,11 +101,10 @@ syscall_thread_enter(struct thread *td, struct sysent **se)
 		oldcnt = (*se)->sy_thrcnt;
 		if ((oldcnt & (SY_THR_DRAINING | SY_THR_ABSENT)) != 0) {
 			*se = &nosys_sysent;
-			return (0);
+			break;
 		}
 		cnt = oldcnt + SY_THR_INCR;
 	} while (atomic_cmpset_acq_32(&(*se)->sy_thrcnt, oldcnt, cnt) == 0);
-	return (0);
 }
 
 void
diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c
index 139a4df57f13..fecc2ca5dcdf 100644
--- a/sys/kern/subr_syscall.c
+++ b/sys/kern/subr_syscall.c
@@ -146,12 +146,8 @@ syscallenter(struct thread *td)
 	if (__predict_false(AUDIT_SYSCALL_ENABLED() ||
 	    SYSTRACE_ENABLED() || !sy_thr_static)) {
 		if (!sy_thr_static) {
-			error = syscall_thread_enter(td, &se);
+			syscall_thread_enter(td, &se);
 			sy_thr_static = (se->sy_thrcnt & SY_THR_STATIC) != 0;
-			if (error != 0) {
-				td->td_errno = error;
-				goto retval;
-			}
 		}
 
 #ifdef KDTRACE_HOOKS
diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h
index c0e5a265fd32..353d5454ec71 100644
--- a/sys/sys/sysent.h
+++ b/sys/sys/sysent.h
@@ -319,7 +319,7 @@ struct nosys_args;
 int	lkmnosys(struct thread *, struct nosys_args *);
 int	lkmressys(struct thread *, struct nosys_args *);
 
-int	syscall_thread_enter(struct thread *td, struct sysent **se);
+void	syscall_thread_enter(struct thread *td, struct sysent **se);
 void	syscall_thread_exit(struct thread *td, struct sysent *se);
 
 int shared_page_alloc(int size, int align);


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a751703.251c5.5352c68c>