Details
- Reviewers
emaste markj kib - Group Reviewers
manpages - Commits
- rS367087: Revise the description of MAP_STACK. In particular, describe the guard
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 34339
Event Timeline
lib/libc/sys/mmap.2 | ||
---|---|---|
349 | The guard is |
lib/libc/sys/mmap.2 | ||
---|---|---|
340–341 | I guess pedantically the stack grows to (len - guard size). How does this sound: This option creates |
lib/libc/sys/mmap.2 | ||
---|---|---|
343 | I would not use a comma here. | |
354–360 | Individually, these two sentences make perfect sense, but taken together they do not. The first sentence is about special "guard" vm map entries that act as reservations for the virtual address region, but the second sentence is about the size of the "red zone" created at the bottom of the virtual address region using the "guard" vm map entry. The size of the former, i.e., the reservation, is NOT determined by the sysctl. But, literally taken together that is what these sentences are saying. In the documentation, I don't think that we should use the word "guard" in describing both the reservation and the red zone. Given its use in the name of the sysctl, I would only use it in conjunction with the red zone. |
After mulling this over for the past day or so, I'd like to propose the following alternative description:
"This option creates a memory region that grows downward on demand and an adjoining guard that both reserves address space for the memory region to grow into and limits the memory region's growth. Together, the memory region and the guard occupy len bytes of the address space. The guard starts at the returned address, and the memory region ends at the returned address plus len bytes. Upon access to the guard, the memory region automatically grows in size, and the guard shrinks by an equal amount. Essentially, the boundary between the guard and the memory region moves downward so that the access falls within the enlarged memory region. However, the guard will never shrink to less than the number of pages specified by the sysctl security.bsd.stack_guard_page, thereby ensuring that a gap for detecting stack overflow always exists between the downward growing memory region and the closest memory region beneath it."
Sounds good to me. Do you want to prepare the patch based on this text, or should I do it ?
lib/libc/sys/mmap.2 | ||
---|---|---|
322 | I'd find this sentence a bit easier to parse if there was a comma after "demand" or if it started with "Creates both a mapped region ... and an adjoining ..." |
lib/libc/sys/mmap.2 | ||
---|---|---|
322 | I'll add "both". I worried that this sentence was too long, but I wanted the first sentence to include "grows downward on demand". |