The usual cause is that the stack (where your buffer
is stored) is not executable. There are primarily two ways around that:
- compile/link such that the stack is marked executable (ie.
gcc -z execstack
) - use
mprotect
at runtime to mark the page where your code is executable