Is there a way to tell kernels “I’m done with this addr space, don’t recycle it and fault me if I access it, but don’t actually keep the page around”? Maybe madvise+mprotect? It would make for cheap use-after-free detection at the cost of eventually running out of address space.
-
-
Exactly. It might be slightly cheaper to madvise with MADV_DONTNEED then mprotect to PROT_NONE, but less portable. MAP_FIXED is the right way.
-
Since it's at page granularity, though, you'll run out of memory rather quick with
@FiloSottile's idea, since all small allocations would have to be rounded up to whole pages. Or you'd have to give up being able to detect UAF for small allocations. - 9 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.