git: 52bd0d1812b6 - main - wait6(2): add user_wait6
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 09 Nov 2026 11:08:09 UTC
The branch main has been updated by brooks:
URL: https://cgit.FreeBSD.org/src/commit/?id=52bd0d1812b6c3fb31db9709ff56393fb082046c
commit 52bd0d1812b6c3fb31db9709ff56393fb082046c
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2026-11-09 11:07:57 +0000
Commit: Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-09 11:07:57 +0000
wait6(2): add user_wait6
sys_wait6 is a little more complicated than typical as compat layers
need to translate siginfo_t.
Effort: CHERI upstreaming
Sponsored by: Innovate UK
Pull Request: https://github.com/freebsd/freebsd-src/pull/2284
---
sys/kern/kern_exit.c | 43 ++++++++++++++++++++++++-------------------
sys/sys/syscallsubr.h | 3 +++
2 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 748164fed948..f4d7d50c7d23 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -925,38 +925,43 @@ kern_wait4(struct thread *td, int pid, int *statusp, int options,
int
sys_wait6(struct thread *td, struct wait6_args *uap)
{
- struct __wrusage wru, *wrup;
siginfo_t si, *sip;
- idtype_t idtype;
- id_t id;
- int error, status;
-
- idtype = uap->idtype;
- id = uap->id;
-
- if (uap->wrusage != NULL)
- wrup = &wru;
- else
- wrup = NULL;
+ int error;
if (uap->info != NULL) {
sip = &si;
bzero(sip, sizeof(*sip));
} else
sip = NULL;
+ error = user_wait6(td, uap->idtype, uap->id, uap->status, uap->options,
+ uap->wrusage, sip);
+ if (uap->info != NULL && error == 0)
+ error = copyout(&si, uap->info, sizeof(si));
+ return (error);
+}
+
+int
+user_wait6(struct thread *td, idtype_t idtype, id_t id, int *statusp,
+ int options, struct __wrusage *wrusage, siginfo_t *sip)
+{
+ struct __wrusage wru, *wrup;
+ int error, status;
+
+ if (wrusage != NULL)
+ wrup = &wru;
+ else
+ wrup = NULL;
/*
* We expect all callers of wait6() to know about WEXITED and
* WTRAPPED.
*/
- error = kern_wait6(td, idtype, id, &status, uap->options, wrup, sip);
+ error = kern_wait6(td, idtype, id, &status, options, wrup, sip);
- if (uap->status != NULL && error == 0 && td->td_retval[0] != 0)
- error = copyout(&status, uap->status, sizeof(status));
- if (uap->wrusage != NULL && error == 0 && td->td_retval[0] != 0)
- error = copyout(&wru, uap->wrusage, sizeof(wru));
- if (uap->info != NULL && error == 0)
- error = copyout(&si, uap->info, sizeof(si));
+ if (statusp != NULL && error == 0 && td->td_retval[0] != 0)
+ error = copyout(&status, statusp, sizeof(status));
+ if (wrusage != NULL && error == 0 && td->td_retval[0] != 0)
+ error = copyout(&wru, wrusage, sizeof(wru));
return (error);
}
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 59ec3640d3ff..1f58fd06cb0b 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -493,6 +493,9 @@ int user_jail_get(struct thread *td, struct iovec *iovp,
updateiov_t *updateiov_f);
int user_jail_set(struct thread *td, struct iovec *iovp,
unsigned int iovcnt, int flags, copyinuio_t *copyinuio_f);
+int user_wait6(struct thread *td, enum idtype idtype, id_t id,
+ int *statusp, int options, struct __wrusage *wrusage,
+ siginfo_t *sip);
/* flags for kern_sigaction */
#define KSA_OSIGSET 0x0001 /* uses osigact_t */