Page MenuHomeFreeBSD

Fixes for pdrfork(2) and tests
ClosedPublic

Authored by kib on Feb 16 2026, 1:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Mar 16, 7:00 PM
Unknown Object (File)
Sun, Mar 15, 12:18 AM
Unknown Object (File)
Sat, Mar 14, 12:31 AM
Unknown Object (File)
Fri, Mar 13, 10:39 AM
Unknown Object (File)
Mon, Mar 9, 2:33 AM
Unknown Object (File)
Sat, Mar 7, 9:48 PM
Unknown Object (File)
Wed, Mar 4, 1:32 AM
Unknown Object (File)
Sun, Mar 1, 9:41 AM
Subscribers

Details

Summary
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

pdfork.2: add EFAULT as possible error, explain some consequences of it


pdrfork(2) tests: RFPROCDESC|RFPROC are required


pdrfork(2) tests: do not rely on (int *)-1 being invalid address

Explicitly mmap guard and use it as the invalid address instead.


pdrfork(2) tests: catch runaway child for EFAULT test


pdrfork(2) tests: split basic_usage

into pdrfork(2) call itself, and basic_usage_tail() that checks the
pdrfork(2) results.


pdrfork(2) tests: should wait for the child to exit


pdrfork(2) tests: enable on x86

Use pfrfork_thread(3) instead of pdrfork(RFSPAWN) to make tests working
on x86.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Feb 16 2026, 1:48 PM
markj added inline comments.
sys/kern/kern_fork.c
220

Indentation here is wrong.

Shouldn't the message be RFPROC and RFPRCDESC are required, passed %#jx or so?

tests/sys/kern/pdrfork.c
97 ↗(On Diff #171967)
116 ↗(On Diff #171967)

Why bother unmapping it?

120 ↗(On Diff #171967)
This revision is now accepted and ready to land.Feb 16 2026, 4:57 PM
kib marked 4 inline comments as done.

Remove munmap(guard).
Fix comments.
Fix style.

This revision now requires review to proceed.Feb 16 2026, 5:18 PM
This revision is now accepted and ready to land.Feb 16 2026, 5:38 PM