aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_syscall.c
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2020-10-01 18:45:31 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2020-10-01 18:45:31 +0000
commit4c6f466cb4bf5f93130fb98b5334f33d2af0f035 (patch)
treee34f7be3ce68c9eb62ac8007edf03b0158447d18 /sys/kern/subr_syscall.c
parent6f64e4f3610dfa0d27722aead4d16621da014024 (diff)
downloadsrc-4c6f466cb4bf5f93130fb98b5334f33d2af0f035.tar.gz
src-4c6f466cb4bf5f93130fb98b5334f33d2af0f035.zip
Notes
Diffstat (limited to 'sys/kern/subr_syscall.c')
-rw-r--r--sys/kern/subr_syscall.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c
index 62b71b227474..5ed9a402caad 100644
--- a/sys/kern/subr_syscall.c
+++ b/sys/kern/subr_syscall.c
@@ -138,7 +138,8 @@ syscallenter(struct thread *td)
(void)sigfastblock_fetch(td);
/* Let system calls set td_errno directly. */
- td->td_pflags &= ~TDP_NERRNO;
+ KASSERT((td->td_pflags & TDP_NERRNO) == 0,
+ ("%s: TDP_NERRNO set", __func__));
if (__predict_false(SYSTRACE_ENABLED() ||
AUDIT_SYSCALL_ENTER(sa->code, td))) {
@@ -149,7 +150,9 @@ syscallenter(struct thread *td)
#endif
error = (sa->callp->sy_call)(td, sa->args);
/* Save the latest error return value. */
- if (__predict_false((td->td_pflags & TDP_NERRNO) == 0))
+ if (__predict_false((td->td_pflags & TDP_NERRNO) != 0))
+ td->td_pflags &= ~TDP_NERRNO;
+ else
td->td_errno = error;
AUDIT_SYSCALL_EXIT(error, td);
#ifdef KDTRACE_HOOKS
@@ -161,7 +164,9 @@ syscallenter(struct thread *td)
} else {
error = (sa->callp->sy_call)(td, sa->args);
/* Save the latest error return value. */
- if (__predict_false((td->td_pflags & TDP_NERRNO) == 0))
+ if (__predict_false((td->td_pflags & TDP_NERRNO) != 0))
+ td->td_pflags &= ~TDP_NERRNO;
+ else
td->td_errno = error;
}
syscall_thread_exit(td, sa->callp);