Page MenuHomeFreeBSD

posix_spawn(): create a guard page below the stack for rfork_thread
ClosedPublic

Authored by kib on Jun 29 2026, 10:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Aug 21, 5:58 PM
Unknown Object (File)
Fri, Aug 21, 3:20 PM
Unknown Object (File)
Wed, Aug 19, 9:54 PM
Unknown Object (File)
Wed, Aug 19, 2:36 PM
Unknown Object (File)
Tue, Aug 18, 7:57 PM
Unknown Object (File)
Mon, Aug 17, 7:47 PM
Unknown Object (File)
Sun, Aug 16, 10:59 PM
Unknown Object (File)
Tue, Aug 11, 6:26 PM
Subscribers

Diff Detail

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

Event Timeline

lib/libc/gen/posix_spawn.c
306

What would prevent us from being able to map over the guard here? I wonder if this should be an assert instead.

kib marked an inline comment as done.Jun 29 2026, 10:48 PM

The cost is +3 syscalls per spawn, but so be it.

lib/libc/gen/posix_spawn.c
306

I dislike asserts in libraries. It is not the library authors to establish the assert policy for the caller.

The check is mostly for correctness. If I somehow missed the correct args to mmap, I can see it immediately.

In D57955#1328646, @kib wrote:

The cost is +3 syscalls per spawn, but so be it.

I think it's defensible for the benefit of the guard page. Worst case scenario, we add a small pool of free stacks to choose from if we get complaints? A little bit of additional complexity, but not terrible.

lib/libc/gen/posix_spawn.c
306

Right, but in this case we're presumably hiding a kernel bug if it does actually fail at this particular point, which feels like a reasonable exception to make for assertions in libraries. I don't insist either way, though.

This revision is now accepted and ready to land.Jun 29 2026, 11:01 PM