Page MenuHomeFreeBSD

libcasper: tolerate kernels without PD_NOWAITPID
ClosedPublic

Authored by delphij on Tue, Oct 6, 7:23 AM.
Tags
None
Referenced Files
F175372634: D60401.id188793.diff
Sat, Oct 10, 9:13 AM
F175351608: D60401.id188849.diff
Sat, Oct 10, 5:28 AM
F175351355: D60401.id188849.diff
Sat, Oct 10, 5:25 AM
F175302027: D60401.diff
Fri, Oct 9, 7:21 PM
F175268949: D60401.diff
Fri, Oct 9, 2:45 PM
F175258108: D60401.diff
Fri, Oct 9, 12:17 PM
Unknown Object (File)
Fri, Oct 9, 8:46 AM
Unknown Object (File)
Fri, Oct 9, 7:02 AM
Subscribers

Details

Summary

Commit 1a296762b3d0 made libcasper pass PD_NOWAITPID to pdfork(2).
Kernels predating the flag (15.1 and earlier, since the flag first
ships in 15.2) reject it with EINVAL, which makes cap_init() and every
service fork fail when a newer world runs on an older kernel, for
example in a poudriere jail.

Add casper_pdfork(), which retries without the flag on EINVAL, and use
it at both pdfork(2) call sites. The retry is safe because the kernel
validates pdfork flags before creating a child. On such kernels the
zombie must still be reaped with waitpid(2), as before the flag was
introduced.

The fallback is compiled out once __FreeBSD_version reaches 1700000,
so it disappears from main when stable/16 branches while remaining in
the stable/15 and stable/16 branches that need it.

MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 77754
Build 74637: arc lint + arc unit

Event Timeline

This is a forward compatibility, which we do not support. You must run the kernel which is newer than the userspace, and there were a lot of time between PD_NOWAITPID introduction and the first use.
But I do not intend to block this.

This revision is now accepted and ready to land.Tue, Oct 6, 7:51 AM