Growing or descending stack
In the context of operating systems and processes, which design is better - A growing or descending stack [User mode/kern开发者_C百科el mode stack] ?
It depends upon placement of the heap and library mappings; if the libraries and heap are low, then growing the stack downwards makes a lot of sense. If the libraries and heap are high, then growing the stack upwards makes a lot of sense. And both seem pretty arbitrary to me.
From a security point of view, I prefer the stack growing upwards, as it reduces the probability of a buffer overflow attack succeeding; there are several architectures that have dedicated stack manipulation instructions that assume a particular direction, so you may not always get to choose (for example, the Motorola 68000 MOVEM intstruction has register indirect with predecrement mode for source and register indirect with postincrement mode for destination operands, but not the other way 'round).
精彩评论