pdrfork(2): do require RFPROCDESC | RFPROC

when RFSPAWN is not specified, as stated in the man page.
rfork(2) cannot modify non-curproc, which is why RFPROC is required,
the syscall cannot act on arbitrary process descriptor.
If RFPROCDESC is not specified, the syscall does not make sense,
use rfork(2).

Reported and tested by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D55306
This commit is contained in:
Konstantin Belousov
2026-02-14 18:38:23 +02:00
parent 995090202c
commit b05be03cee
2 changed files with 10 additions and 3 deletions
+5 -3
View File
@@ -114,11 +114,13 @@ for a description of the possible
flags.
The
.Fn pdrfork
system call requires that the
system call requires that both the
.Va RFPROC
or
and
.Va RFPROCDESC
flags, or
.Va RFSPAWN
flag is specified.
flag are specified.
.Pp
.Fn pdgetpid
queries the process ID (PID) in the process descriptor
+5
View File
@@ -214,6 +214,11 @@ sys_pdrfork(struct thread *td, struct pdrfork_args *uap)
fr.fr_flags = RFFDG | RFPROC | RFPPWAIT | RFMEM | RFPROCDESC;
fr.fr_flags2 = FR2_DROPSIG_CAUGHT;
} else {
if ((uap->rfflags & (RFPROC | RFPROCDESC)) !=
(RFPROC | RFPROCDESC)) {
return (EXTERROR(EINVAL,
"RFPROC|RFPROCDESC required %#jx", uap->rfflags));
}
fr.fr_flags = uap->rfflags;
}