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

user104787
  • 179
  • 1
  • 4
  • 12
  • 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 http://stackoverflow.com/questions/664744/what-is-the-direction-of-stack-growth-in-most-modern-systems . – dave_thompson_085 Jul 17 '16 at 04: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 Jul 17 '16 at 19:09

1 Answers1

2

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

theJack
  • 131
  • 4