WCU / Cybersecurity
~/CSC 472/Class 02/KP 07
Class 02 · KP 07 / 23

push, pop, and RSP

  • The stack is a LIFO region; RSP always points at the current top (lowest in-use address).
  • push decrements RSP by 8, then stores.
  • pop loads, then increments RSP by 8.
push rax    ; RSP = RSP - 8 ; [RSP] = rax
pop  rbx    ; rbx = [RSP]   ; RSP = RSP + 8
Key Takeaway

Because the stack grows DOWN, a buffer that is written UPWARD (like a string copy) overruns toward higher addresses — straight into saved RBP and the saved return address.