How are buffer overflows used to exploit computers?
How is one able to execute arbitrary code simply by causing stack or heap overflows?
I understand that
The stack contains both data and return address when you jump into a subroutine. If you manage to put a specific address on the stack where the return address is, you can force the CPU to jump to a particular memory location, the one where y ou put your own code. That's for buffer overflows. Heap overflows is a bit different and more difficult to exploit.
Stack overflows are just indication that you've run out of stack space (which is generally more limited, especially in the kernel).