[LLVMdev] [PATCH] Protection against stack-based memory corruption errors using SafeStack

David Chisnall David.Chisnall at cl.cam.ac.uk
Tue Nov 4 01:07:37 PST 2014


On 4 Nov 2014, at 00:36, Kostya Serebryany <kcc at google.com> wrote:

> You at least increase the memory footprint by doubling the stack sizes. 

Not quite.  The space overhead is constant for each stack frame - you just need to keep track of the top of two stacks, rather than one.  The important overhead is that you reduce locality of reference.  You will need a minimum of two cache lines for each stack frame instead of one.  In practice, this is not a huge problem, because you need several cache lines live for good performance of the stack and the total number of lines is not much different.  

There are likely to be some pathological cases though, when both the safe and unsafe stacks have the same alignment for the top and you are dealing with some other heap data with the same alignment.  This will increase the contention in set-associative cache lines and may cause more misses.

David





More information about the llvm-dev mailing list