What is the role of stack in a microprocessor?
Stack is used largely during a function call but depending on the language and level of programming it may be used to temporarily store processor register data or other variables.
Further, the stack may also be used for short-term large-scale storage of data when using recursive functions that store partial data in the stack and call themselves again.
The generic use of stack is for,
And, yes, stack is also used for exploits.
Its nature of carrying the return-address to where a called function returns back,
coupled with the weakness of array-bounds checks in the C
language, gives a very
nice way to cause buffer overflows in the stack of a vulnerable (unsafely written) program.