Conversation

I made a video about how hardened malloc can help secure against very simple heap overflows. If you have time, I'd be happy if you could review the video and tell me where I made mistakes, and what more I can learn about libhardened_malloc.
1
Replying to
One thing to note is that when canaries are enabled (which is the default), they add 8 bytes to the size of allocation requests, so some allocations are pushed into a higher size class, which needs to be taken into account when checking the table to determine the size class.
1
Replying to and
The offset test prints the measured offset between different size classes and has to take canaries into account: github.com/GrapheneOS/har. It's a useful way of demonstrating the isolated regions for each size class and randomization of the guard regions and slab slot selection.
1
Replying to and
Also, from the maps outside, either in gdb or /proc/PID/maps, you'll be able to see the randomly sized guard regions placed around large allocations, along with the guard slab feature. Both of these are enabled by default, and the default guard slab setting is very aggressive.
1
Replying to and
At the moment, the only randomization for slabs is the high entropy isolated base for each region along with random slot selection within slabs. Randomizing the location of guard slabs and selection of slabs themselves rather than just slots within is planned, just not high prio.