Smashing the stack Flashcards
buffer
contiguous block of computer memory that holds multileinstance of the same data type
arrays
variable in c
can be declared either static or dynamic
static variables
allocated at load time on the data segment
dynamic
dynamic variables are allocated at run time on the stack
to overflow
to flow/fill over the top, brims or bounds
stack-based buffer overflows
overflow of dynamic buffers
three regions to organize a process in memory
text, data, and stack
text region
fixed by the program and includes code (instructions) and read-only data
corresponds to the text section of the executable file
normally marked read-only
attempts to write to it will result in a segmentation violation
data region
contains initialized and uninitialized data
stores static variables
corresponds to data-bss section of executable file
its size can be changed with the brk(2) system call
if xpansion of the bss data or the user stack exhausts available memory, proces is blocked and reschedule to runagain with larger memory space
new memory is added…
between the data and stack segments
what is “a stack”
abstract data type
stack of objects property
las object placed on the stack will be the first obect removed– last in, first out queue- LIFO
PUSH operation
adds an element at the top of the stack
POP operation
reduces the stack size by one by removing the last element at the top of the stack
a procedure call…
alters the flow of control like a jump
unline a jump, when finished performing its task, a function returns control to the statement or instruction following the call
what does the stack do?
used to dynamically allocated the loca variables used in functions
to pass parameters to the functions
to return values from the function
The stack region
a contiguous block of memory containing data.
SP- stack pointer
a register that points to the top of the stack
bottom of the stack
at a fixed address
size of the stack
its size is dynamically adjusted by the kernel at run time
what PUSHes and POPs
the CPU implements instruction to PUSH onto and POP off of the stack
what does the stack consist of?
logical stack frames that are pushed when calling a function and popped when returning
what is a stack frame?
a stack frame contains the parameters to a function, its local varaibles,a dn teh data necessary to recover the previous stack frame, including the value of the instruction poiner at the time of the function call
how does the stack grow on many computers including INtel, motorola, sparc, and MIPS processors?
stack grows down towards lower memory addresses
stack pointer can either point to
a) the last address on the stack
b) or the next free available address after the stack
stack pointer (sP)
points to the top of the stack (lowest numericaladress)
frame pointer (fp)
points to a fixed location within a frame
also known as local base pointer,