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
39024a8914 ("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
Differential Revision:	https://reviews.freebsd.org/D57848
This commit is contained in:
Kyle Evans committed 2026-06-30 14:12:10 -05:00
1 parent 1756d1cab3
commit eca26803d8
4 files changed
+6 -15

No files matched your search

+2 -6
View File
@@ -2690,7 +2690,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;
@@ -2734,12 +2734,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];
+2 -3
View File
@@ -88,7 +88,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;
@@ -100,11 +100,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
+1 -5
View File
@@ -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
+1 -1
View File
@@ -328,7 +328,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);