git: 9f47314ebdb6 - main - pdrfork(2): add kern_pdrfork
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 12 Nov 2026 11:01:54 UTC
The branch main has been updated by brooks:
URL: https://cgit.FreeBSD.org/src/commit/?id=9f47314ebdb61a9d7368f2bc75b122d62be5694d
commit 9f47314ebdb61a9d7368f2bc75b122d62be5694d
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2026-11-12 11:01:30 +0000
Commit: Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-12 11:01:30 +0000
pdrfork(2): add kern_pdrfork
Effort: CHERI upstreaming
Sponsored by: DARPA, AFRL
Pull Request: https://github.com/freebsd/freebsd-src/pull/2284
---
sys/kern/kern_fork.c | 35 ++++++++++++++++++++---------------
sys/sys/syscallsubr.h | 1 +
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 839fa1c440f7..9175a48c47ee 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -209,6 +209,12 @@ sys_rfork(struct thread *td, struct rfork_args *uap)
int
sys_pdrfork(struct thread *td, struct pdrfork_args *uap)
+{
+ return (kern_pdrfork(td, uap->fdp, uap->pdflags, uap->rfflags));
+}
+
+int
+kern_pdrfork(struct thread *td, int *fdp, int pdflags, int rfflags)
{
struct fork_req fr;
struct filecaps fcaps;
@@ -217,35 +223,34 @@ sys_pdrfork(struct thread *td, struct pdrfork_args *uap)
bzero(&fr, sizeof(fr));
fd = -1;
- AUDIT_ARG_FFLAGS(uap->pdflags);
- AUDIT_ARG_CMD(uap->rfflags);
+ AUDIT_ARG_FFLAGS(pdflags);
+ AUDIT_ARG_CMD(rfflags);
- if ((uap->rfflags & (RFSTOPPED | RFHIGHPID)) != 0)
+ if ((rfflags & (RFSTOPPED | RFHIGHPID)) != 0)
return (EXTERROR(EINVAL,
- "Kernel-only flags %#jx", uap->rfflags));
+ "Kernel-only flags %#jx", rfflags));
/* RFSPAWN must not appear with others */
- if ((uap->rfflags & RFSPAWN) != 0) {
- if (uap->rfflags != RFSPAWN)
+ if ((rfflags & RFSPAWN) != 0) {
+ if (rfflags != RFSPAWN)
return (EXTERROR(EINVAL,
- "RFSPAWN must be the only flag %#jx",
- uap->rfflags));
+ "RFSPAWN must be the only flag %#jx", rfflags));
fr.fr_flags = RFFDG | RFPROC | RFPPWAIT | RFMEM | RFPROCDESC;
fr.fr_flags2 = FR2_DROPSIG_CAUGHT;
} else {
- if ((uap->rfflags & (RFPROC | RFPROCDESC)) !=
+ if ((rfflags & (RFPROC | RFPROCDESC)) !=
(RFPROC | RFPROCDESC)) {
return (EXTERROR(EINVAL,
- "RFPROC|RFPROCDESC required %#jx", uap->rfflags));
+ "RFPROC|RFPROCDESC required %#jx", rfflags));
}
- fr.fr_flags = uap->rfflags;
+ fr.fr_flags = rfflags;
}
fr.fr_pidp = &pid;
fr.fr_pd_fd = &fd;
- fr.fr_pd_flags = uap->pdflags;
+ fr.fr_pd_flags = pdflags;
filecaps_fill(&fcaps);
- if ((uap->pdflags & PD_PTRACE_CAP) == 0)
+ if ((pdflags & PD_PTRACE_CAP) == 0)
cap_rights_clear(&fcaps.fc_rights, CAP_PTRACE);
fr.fr_pd_fcaps = &fcaps;
error = fork1(td, &fr);
@@ -253,8 +258,8 @@ sys_pdrfork(struct thread *td, struct pdrfork_args *uap)
td->td_retval[0] = pid;
td->td_retval[1] = 0;
if ((fr.fr_flags & (RFPROC | RFPROCDESC)) ==
- (RFPROC | RFPROCDESC) || uap->rfflags == RFSPAWN)
- error = copyout(&fd, uap->fdp, sizeof(fd));
+ (RFPROC | RFPROCDESC) || rfflags == RFSPAWN)
+ error = copyout(&fd, fdp, sizeof(fd));
}
return (error);
}
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index f50342308aed..1cda115cf738 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -406,6 +406,7 @@ int kern_openatfp(struct thread *td, int dirfd, const char *path,
int kern_pathconf(struct thread *td, const char *path,
enum uio_seg pathseg, int name, u_long flags, long *valuep);
int kern_pdfork(struct thread *td, int *fdp, int flags);
+int kern_pdrfork(struct thread *td, int *fdp, int pdflags, int rfflags);
int kern_pipe(struct thread *td, int fildes[2], int flags,
struct filecaps *fcaps1, struct filecaps *fcaps2);
int kern_pipe2(struct thread *td, int *ufildes, int flags);