Non-executable stack and heap (original) (raw)

Starting with version 2.0, NetBSD supports non-executable mappings on platforms where the hardware allows it. Process stack and heap mappings are non-executable by default. This makes exploiting potential buffer overflows harder. NetBSD supports PROT_EXEC permission via mmap() for all platforms where the hardware differentiates execute access from data access, though not necessarily with single-page granularity. When the hardware has a larger granularity, the rule is that if any page in the larger unit is executable, then the entire larger unit is executable, otherwise the entire larger unit is not executable.

No compile-time option is needed to enable this software support, it's always available.

This support is also used on some kernel configurations for PaX mprotect (also known as W^X), which forbids even a single page from being mapped both writable and executable. See paxctl(8) for more information.

Supported platforms

Here is a list of support levels based on hardware limitations. In this list "the stack" refers to the traditional UNIX process stack, not pthreads stacks.