3

Question-

Is there a command on Linux systems to see if execution from the stack is allowed?

Background-

Doing a homework assignment that requires a buffer overflow, injecting code into the stack, and overwriting a return address that will set the instruction pointer to the injected code. Everything looks good when stepping though with GDB, but segfaults when trying to execute the first line from the stack. The instruction pointer changes to the correct location, and the instruction is a NOP for testing purposes. I'm wondering if the system is preventing execution from the stack.

Thank you.

jeff
  • 162
  • 8
  • Did you try execstack? => http://stackoverflow.com/questions/6482759/execute-code-in-processs-stack-on-recent-linux – Antti Mar 23 '13 at 05:58
  • No I haven't. But that's the answer. For anyone else that stumbles across this. "ps -u user" to find PID, then "pmap -x PID" and check line that says "stack." If the x(execute) is missing, type "execstack -s filename" Thanks for the help – jeff Mar 23 '13 at 06:20
  • Still segfaults under regular execution i.e. ./filename, but now works correctly under GDB, which should be good enough for homework. – jeff Mar 23 '13 at 06:48

1 Answers1

0

Did you try execstack? => stackoverflow.com/questions/6482759/… – Antti yesterday

For anyone else that stumbles across this. "ps -u user" to find PID, then "pmap -x PID" and check line that says "stack." If the x(execute) is missing, type "execstack -s filename"

Still segfaults under regular execution i.e. ./filename, but now works correctly under GDB

jeff
  • 162
  • 8