Re:How OpenBSD Leverages Malloc to Find Bugs
by eridius on Monday November 28, 2011 @01:49PM
(#3287062)
Why 2 4k pages? If I'm allocating 1k of memory, what does having an entire extra page get me?
[ Parent
| on HN ]
Re:How OpenBSD Leverages Malloc to Find Bugs
by jsnell on Monday November 28, 2011 @01:57PM
(#3287093)
The second 4k is a guard page, to catch buffer overflows. So the heap looks like:
3k empty, 1k data, 4k empty and read/write-protected.
The extra page is needed since you can't set the memory protection flags at a higher granularity.
Re:How OpenBSD Leverages Malloc to Find Bugs
by eridius on Tuesday November 29, 2011 @01:18PM
(#3291419)
Ah. It sounded like you were mapping 2 4k pages for the allocation itself, aligning the allocation at the end of that 2-page span, and then mapping the following page and marking it as denied.