0

when I read something about buffer overflows on the stack, the most or some tutorials show me examples about overwriting local variables (pointers) and then overwriting pointers in the global offset table. But in some tutorials the stack grows upwards and in some it grows downwards, why? Is the architecture of every system in every tutorial different, I mean little-endian or big-endian. In the article of the Phrack magazine, the stack grows upwards and in the book the art of exploitation also. And in this article it grows downwards. But the operating systems in both tutorials are UNIX systems, so why there is such a difference?. And on my android phone the stack grows upwards and on my Ubuntu Desktop it grows downwards. It irritates me :(

2
  • 2
    Big-endian and little-endian is about bytes in a larger unit like a word, or sometimes bits in a byte (or word etc); it has nothing to do with stack direction. But the Phrack you link is for a downward-growing stack (on x86), not upward. Unix is based on C, and C doesn't actually require a stack at all, much less a particular direction. (C does require recursive activation records, and on nearly all platforms stack is a good way to do that, but it isn't required.) See stackoverflow.com/questions/664744/… . Commented Jul 17, 2016 at 4:43
  • @dave_thompson_085 really interesting, I'd wondered (as any C programmer has) about alternative recursion schemes without stacks and your link blew my mind!
    – zetavolt
    Commented Jul 17, 2016 at 19:09

1 Answer 1

2

The direction of stack growth is hardware dependent. On x86 architectures, it grows downward, but it may be different on other architectures.

1
  • 1
    IIRC, the Z80 has an upwards-growing stack.
    – jpaugh
    Commented Oct 9, 2017 at 19:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .