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 :(

  • 1
    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/… . – dave_thompson_085 Jul 17 '16 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! – ŹV - Jul 17 '16 at 19:09
1

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

| improve this answer | |
  • 1
    IIRC, the Z80 has an upwards-growing stack. – jpaugh Oct 9 '17 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.