← Back to context

Comment by weebull

10 months ago

> The advantage of storing them elsewhere is not quite clear (unless you have hardware support for things like shadow stacks).

The classic buffer overflow issue should spring immediately to mind. By having a separate return address stack it's far less vulnerable to corruption through overflowing your data structures. This stops a bunch of attacks which purposely put crafted return addresses into position that will jump the program to malicious code.

It's not a panacea, but generally keeping code pointers away from data structures is a good idea.