Page MenuHomeFreeBSD

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

Authored by kib on Mon, Jun 29, 10:10 PM.

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.Mon, Jun 29, 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.Mon, Jun 29, 11:01 PM