A Little more Hardware
- Remember, memory is memory
- The cpu will interpret contents based on usage.
- Ascii,
- Integer
- Floating Point
- Or even instructions.
- If a piece of data is loaded into the IR, it is an instruction.
- But some data could yield an illegal instruction.
- The cpu will go to an exception handler when an illegal instruction is executed.
- Review of Setuid programs.
- These are programs that allow normal users to become the superuser
- They are marked by a "s" in the execute bit for user.
- These are requred for programs that
- Access/change resources like configuration files.
- find /usr/bin -perm -u+s
- Most of these allow or require additional input in interactive mode.
- Which would make a buffer overflow possible.
- These must be coded carefully.
- look at chfn.c code.
- Specifically ask_new_field
- This uses getline. See man page.
- C style strings.
- A null terminated array of strings.
-
const char * s
- \0 is null.
- c has library functions (string.h) which help with this
- strlen
- strcmp
- strdup
- And many more
- All of these rely on the string being null terminated.
- Take a look at stringDemo.c
- no op instruction
- For modern pipelined systems this is a requirement.
- reference for intel assembly.
- Finally the activation record
- From Cooper and Torczon
- In intel, the frame pointer is register epb.
- GDB
- Programs compiled with a -g (in gcc/g++) can be debugged with an interactive debugger.
-
gdb
is this debugger.
-
gdb progname
- some commands
-
b(reak) linenum
will break on given linenum.
-
b functionName
will work too.
-
run
will run until the break point is hit or the program exits.
-
s
will step one instruction
-
c
will continue to the break point.
-
l(ist) linenu
will list starting at that line number.
-
p varname
will print that variable, but only after it has been defined.
-
p/x $regname
will print the register value in hex.
- epb is the frame pointer.
- pc is the program counter.
-
p/x $pc
-
x address
examine the value of a memory address.
-
display/#i $pc
display # next instructions every execution