What is the difference between a stack overflow and a buffer overflow in programming?
Let me explain in a simpler way with a diagram of RAM. Before jumping into it, I suggest reading about StackFrame, Heap Memory.
As you can see, the Stack grows downwards (showed by arrow) assuming it's stack. The kernel code, text, data all are static data, so they are fixed. The heap portion being dynamic grows upwards (showed by arrow).