The question is as simple as that:
- Is it possible to say to the kernel, hey, the address region that goes from address X to X + size is forbidden, in the sense that there can’t be no mappings there. I don’t want that region to be populated with virtual memory areas.
What I’m trying to achieve is:
- I have a mmapped region of size 4GiB, and I want to make sure that, if there’s a read or write overflow (an offset that is too big for example) before or after the region, a segfault must happen. I don’t want an overflow to accidentally succeed because there’s something else there.
- The maximum overflow possible is 4GiB. I know I could create then a 4 * 3 GiB mmap with PROT_NONE and then add the actual permissions to the central 4GiB region, but that would cause the process to have 12GiB of virtual memory which could scare some people (even if no RAM is being actually waste).
- So I would like to make sure there’s literally a void before and after my memory region that is big enough to make sure no possible overflow would accidentally succeed.
Is that even possible?