Why don't stacks grow upwards (for security)?

Posted by AshleysBrain on Stack Overflow See other posts from Stack Overflow or by AshleysBrain
Published on 2010-04-30T12:35:31Z Indexed on 2010/04/30 12:47 UTC
Read the original article Hit count: 306

Filed under:
|
|
|
|

This is related to the question 'Why do stacks typically grow downwards?', but more from a security point of view. I'm generally referring to x86.

It strikes me as odd that the stack would grow downwards, when buffers are usually written to upwards in memory. For example a typical C++ string has its end at a higher memory address than the beginning.

This means that if there's a buffer overflow you're overwriting further up the call stack, which I understand is a security risk, since it opens the possibility of changing return addresses and local variable contents.

If the stack grew upwards in memory, wouldn't buffer overflows simply run in to dead memory? Would this improve security? If so, why hasn't it been done? What about x64, do those stacks grow upwards and if not why not?

© Stack Overflow or respective owner

Related posts about cpu

Related posts about architecture