title: GDB ret "cannot access memory at address"
body: <p>Put simply:</p>
  
  <ol>
  <li>top of stack <code>($esp) = 0xbffff49c</code>.</li>
  <li>gdb executes <code>ret</code> instruction, which responds with <code>Cannot access memory at address 0x90909094</code>.</li>
  </ol>
  
  <p>What reason would gdb be trying to access <code>0x90909094</code> when the value at the top of the stack is <code>0xbffff49c</code>?</p>
  
  <p>Random info (in case it's needed):</p>
  
  <pre><code>[----------------------------------registers-----------------------------------]
  EAX: 0x5a ('Z')
  EBX: 0xb7fbeff4 --&gt; 0x15ed7c 
  ECX: 0xbffff428 --&gt; 0xb7fbf4e0 --&gt; 0xfbad2a84 
  EDX: 0xb7fc0360 --&gt; 0x0 
  ESI: 0x0
  EDI: 0x0 
  EBP: 0x90909090 
  ESP: 0xbffff49c --&gt; 0xbffff450 --&gt; 0xdb31c031 
  EIP: 0x80485dd (&lt;greeting+113&gt;: ret)
  EFLAGS: 0x292 (carry parity ADJUST zero SIGN trap INTERRUPT direction overflow)
  [-------------------------------------code-------------------------------------]
     0x80485d0 &lt;greeting+100&gt;:    mov    DWORD PTR [esp],0x80487f4
     0x80485d7 &lt;greeting+107&gt;:    call   0x80483f0 &lt;printf@plt&gt;
     0x80485dc &lt;greeting+112&gt;:    leave  
  =&gt; 0x80485dd &lt;greeting+113&gt;:    ret    
     0x80485de &lt;checkPassword&gt;:   push   ebp
     0x80485df &lt;checkPassword+1&gt;: mov    ebp,esp
     0x80485e1 &lt;checkPassword+3&gt;: push   ebx
     0x80485e2 &lt;checkPassword+4&gt;: sub    esp,0x64
  [------------------------------------stack-------------------------------------]
  0000| 0xbffff49c --&gt; 0xbffff450 --&gt; 0xdb31c031 
  0004| 0xbffff4a0 --&gt; 0x0 
  0008| 0xbffff4a4 --&gt; 0xbffff564 --&gt; 0xbffff6b2 ("/root/Desktop/CSCE_526/task1")
  0012| 0xbffff4a8 --&gt; 0x804876b (&lt;__libc_csu_init+11&gt;:   add    ebx,0x1351)
  0016| 0xbffff4ac --&gt; 0xb7fbeff4 --&gt; 0x15ed7c 
  0020| 0xbffff4b0 --&gt; 0x8048760 (&lt;__libc_csu_init&gt;:  push   ebp)
  0024| 0xbffff4b4 --&gt; 0x0 
  0028| 0xbffff4b8 --&gt; 0xbffff538 --&gt; 0x0 
  [------------------------------------------------------------------------------]
  gdb-peda$ n
  Cannot access memory at address 0x90909094
  </code></pre>
  
  <p>I'm overflowing a buffer and trying to get it to execute some shellcode, but I'm not sure if those details are relevant considering the simplicity of the question: why is ret trying to access data not on the top of the stack?</p>