Unit Tests Skipped
"within its address range" or "overapping its address range" or something like that?
The guard prevents mappings without the MAP_FIXED flag from overlapping its address range.
results in the SIGSEGV signal being delivered to the thread.
Guards allow the reservations to be created in the address space, which can be replaced by actual mappings later on.
For instance, the system uses guards to prevent the inadvertent use of regions into which stacks created with MAP_STACK will automatically grow.
I would write this sentence as
"mmap(2) will not create mappings in the address range of a guard unless the request specifies MAP_FIXED. Guards can be destroyed with munmap(2)."
In particular, since we're being careful to distinguish between guards and mappings, it seems strange to state that a guard can be unmapped.
"results in the delivery of a SIGSEGV signal to the thread"
"Guards allow a process to create reservations in its address space, which..."
I think that there are a few things missing here.
- If I'm using MAP_STACK, do I have to use MAP_GUARD in some way? I don't think the words "the system uses guards" are specific enough. That said, the way that I would handle this is to update the description of MAP_STACK.
- What happens if I specify MAP_GUARD in conjunction with a "prot" other than PROT_NONE or an "fd" other than -1?
- What happens to a guard on a fork()?
I don't see the harm in tweaking the sentence to avoid any possible confusion: "Any memory access by a thread to the guarded range results in the delivery of a SIGSEGV to that thread."
I would suggest moving this (minus the "For instance,") to the description of MAP_STACK.
Move note about MAP_STACK use of MAP_GUARD to MAP_STACK block.
Document EINVAL on invalid MAP_GUARD call, explicitely listing the requirements.
Also remove MAP_HASSEMAPHORE, this will be the preliminary conflict. The option is in sys/mman.h, it is not useful but AFAIK cannot be easily removed.
This is complex. Suggested:
Stacks created with .Dv MAP_STACK automatically grow. Guards prevent inadvertent use of the regions into which those stacks can grow without requiring mapping the whole stack in advance.