nanovms / nanos

A kernel designed to run one and only one application in a virtualized environment
https://nanos.org
Apache License 2.0
2.66k stars 137 forks source link

mmap(2): add support for MAP_GROWSDOWN flag #2060

Closed francescolavra closed 2 months ago

francescolavra commented 2 months ago

A mapping with this flag can be expanded downwards dynamically (up to the PROCESS_STACK_SIZE limit) by "touching" addresses lower than the base of the mapping. This feature requires that a guard gap is kept between a MAP_GROWSDOWN mapping and any adjacent mappings. The second commit implements enforcing of the guard gap next to the process stack, which is a security feature because it greatly decreases the likelihood of a stack overflow not being detected and prevents the exploitation of many application vulnerabilities that involve overflowing the stack. The first commit fixes a bug in the paging code that was causing sporadic failures when running the mmap runtime test.