1 Carnegie Mellon Recitation 15 15-213: Introduction to Computer Systems Recitation 15: December 3, 2012 Daniel Sedra Section C.

Slides:



Advertisements
Similar presentations
Recitation 4 Outline Buffer overflow –Practical skills for Lab 3 Code optimization –Strength reduction –Common sub-expression –Loop unrolling Reminders.
Advertisements

David Brumley Carnegie Mellon University Credit: Some slides from Ed Schwartz.
ITEC 352 Lecture 27 Memory(4). Review Questions? Cache control –L1/L2  Main memory example –Formulas for hits.
CS 4284 Systems Capstone Godmar Back Linking and Loading.
Final Exam Review Monday December 1, 2014 TJ O’Connor.
Review: Software Security David Brumley Carnegie Mellon University.
Stack buffer overflow.
Memory Image of Running Programs Executable file on disk, running program in memory, activation record, C-style and Pascal-style parameter passing.
Practical Session 3. The Stack The stack is an area in memory that its purpose is to provide a space for temporary storage of addresses and data items.
1 Homework Reading –PAL, pp , Machine Projects –Finish mp2warmup Questions? –Start mp2 as soon as possible Labs –Continue labs with your.
Recitation 11: I/O Problems Andrew Faulring Section A 18 November 2002.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2011.
CS 3204 Operating Systems Godmar Back Lecture 11.
Carnegie Mellon Introduction to Computer Systems /18-243, spring 2009 Recitation, Jan. 14 th.
1 Carnegie Mellon Stacks : Introduction to Computer Systems Recitation 5: September 24, 2012 Joon-Sup Han Section F.
Practical Session 4. Labels Definition - advanced label: (pseudo) instruction operands ; comment valid characters in labels are: letters, numbers, _,
Recitation 11: 11/18/02 Outline Robust I/O Chapter 11 Practice Problems Annie Luo Office Hours: Thursday 6:00 – 7:00 Wean.
Recitation 6 – 2/26/01 Outline Linking Exam Review –Topics Covered –Your Questions Shaheen Gandhi Office Hours: Wednesday.
Carnegie Mellon 1 Midterm Review : Introduction to Computer Systems October 14, 2013.
Carnegie Mellon /18-213: Introduction to Computer Systems Instructors: Anthony Rowe, Seth Goldstein and Gregory Kesden 27 th (and last) Lecture,
What is exactly Exploit writing?  Writing a piece of code which is capable of exploit the vulnerability in the target software.
Recitation 11 (Nov. 22) Outline Lab 6: interposition test Error handling I/O practice problem Reminders Lab 6: Due Tuesday Minglong Shao
CS415 C++ Programming Takamitsu Kawai x4212 G11 CERC building WV Virtual Environments Lab West Virginia University.
CSE 351 Final Exam Review 1. The final exam will be comprehensive, but more heavily weighted towards material after the midterm We will do a few problems.
1 Understanding Pointers Buffer Overflow. 2 Outline Understanding Pointers Buffer Overflow Suggested reading –Chap 3.10, 3.12.
CS 155 Section 1 PP1 Eu-Jin Goh. Setting up Environment Demo.
Reminder Bomb lab is due tomorrow! Attack lab is released tomorrow!!
Carnegie Mellon Introduction to Computer Systems / Spring 2009 March 23, 2009 Virtual Memory.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Tarek Abdelzaher Vikram Adve CS241 Systems Programming System Calls and I/O.
CS429 Computer Architecture Topics Simple C program Basic structure, functions, separate files Compilation Phases, options Assembler GNU style, byte ordering,
OS Labs 2/25/08 Frans Kaashoek MIT
Practical Session 4. GNU Linker Links object files together Used as the last step in the compilation We will use ld to link together compiled assembly.
Recitation 3 Outline Recursive procedure Complex data structures –Arrays –Structs –Unions Function pointer Reminders Lab 2: Wed. 11:59PM Lab 3: start early.
Carnegie Mellon Midterm Review : Introduction to Computer Systems October 15, 2012 Instructor:
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2014.
Practical Session 4. GNU Linker Links object files together Used as the last step in the compilation We will use ld to link together compiled assembly.
Using System Calls (Unix) Have to tell compiler (if C/C++) where to find the headers, etc. – i.e., the “include” files May have to tell compiler where.
“Success consists of going from failure to failure without loss of enthusiasm.” Winston Churchill.
Introduction to Computer Systems Topics: Assembly Stack discipline Structs/alignment Caching CS 213 S ’12 rec8.pdf “The Class That Gives CMU Its.
Practical Session 3 Computer Architecture and Assembly Language.
Practical Session 3.
Content Coverity Static Analysis Use cases of Coverity Examples
Computer Architecture and Assembly Language
Final Exam Review : Introduction to Computer Systems Recitation 15: Monday, Dec. 2nd, 2013 Marjorie Carlson Section A.
Computer Architecture and Assembly Language
Protection of System Resources
Anton Burtsev February, 2017
Homework Reading Machine Projects Labs PAL, pp ,
CS 5204 Operating Systems Linking and Loading Godmar Back.
Introduction to Compilers Tim Teitelbaum
Nikhil, Kashish, Krishanu, Stan
System Structure B. Ramamurthy.
CS241 Section: Week 10.
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
CS 4284 Systems Capstone Linking and Loading Godmar Back.
System Structure and Process Model
Assembly Language Programming II: C Compiler Calling Sequences
Bits and Bytes Topics Representing information as bits
Machine Level Representation of Programs (IV)
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2015.
Getting Started Download the tarball for this session. It will include the following files: driver 64-bit executable driver.c C driver source bomb.h declaration.
CNT4704: Analysis of Computer Communication Network Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Fall 2011.
Lecture 2 SCOPE – Local and Global variables
Introduction to Static Analyzer
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2016.
Getting Started Download the tarball for this session. It will include the following files: driver 64-bit executable driver.c C driver source bomb.h declaration.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2013.
Computer Architecture and System Programming Laboratory
Computer Architecture and System Programming Laboratory
Computer Architecture and System Programming Laboratory
Presentation transcript:

1 Carnegie Mellon Recitation : Introduction to Computer Systems Recitation 15: December 3, 2012 Daniel Sedra Section C

2 Carnegie Mellon Topics News Proxylab Exam review :>) Wrap up

Final and Review Session News Final is on Monday, December 10 from 8:30-11:30 am in UC McConomy, PH 100, and PH 125C Final review session is on Sunday, December 9 in GHC 4401 from 2-5 pm and bring questions! 3

4 Carnegie Mellon Proxylab News Proxylab due on Sunday, Dec 2 Last date to handin is Wednesday, Dec 5 Each group gets 2 grace days

5 Carnegie Mellon Things To Know: First Half  Integer and floating point numbers  X86 and X86-64 assembly  Procedure calls and stack discipline  Memory layout  Memory hierarchy and caching Reviewed today

Things To Know: Second Half Signals and processes Concurrent programming and threading Virtual memory Dynamic Memory Networks 6

7 Carnegie Mellon Virtual Memory

8 Carnegie Mellon Virtual Memory

9 Carnegie Mellon Virtual Memory The setup is a 2-level page table for a 32-bit Intel system with 4 KB page tables. Reference diagrams above. The relevant contents of memory are shown; anything not shown is presumed zero. The Page Directory Base Address is 0x0c23b000. For the following problems, perform the virtual to physical address translation. If an error occurs at any point that would prevent the system from performing lookup, circle FAILURE and not the address that caused it.

10 Carnegie Mellon Virtual Memory

11 Carnegie Mellon Virtual Memory 1.Read from virtual address 0x080016ba a)Physical address of PDE: b)Physical address of PTE: c)Success, the physical address is: or Failure, the entry causing it was:

12 Carnegie Mellon Virtual Memory 1.Read from virtual address 0x080016ba a)Physical address of PDE: 0xc23b080 b)Physical address of PTE: 0x55004 c)Success, the physical address is: 0x8974d6ba or Failure, the entry causing it was:

13 Carnegie Mellon Virtual Memory 1.Read from virtual address 0x9fd28c10 a)Physical address of PDE: b)Physical address of PTE: c)Success, the physical address is: or Failure, the entry causing it was:

14 Carnegie Mellon Virtual Memory 1.Read from virtual address 0x9fd28c10 a)Physical address of PDE: 0xc23b9fc b)Physical address of PTE: c)Success, the physical address is: or Failure, the entry causing it was: 0xc23b9fc

15 Carnegie Mellon I/O Consider the following code assuming all system calls to read() and write() are atomic of each other. foo.txt = “ABCDEFG” Determine 1. The output of the program. 2. The final contents of foo.txt.

16 Carnegie Mellon I/O void read_and_print_one(int fd){ char c; read(fd, &c, 1); printf(“%c”, c); fflush(stdout); } int main(int argc, char * argv[]){ int fd1 = open(“foo.txt”, O_RDONLY); read_and_print_one(fd1); read_and_print_one(fd2); if ( !fork() ){ read_and_print_one(fd2); close(fd2); fd2 = dup(fd1); read_and_print_one(fd2); } else{ wait(NULL); read_and_print_one(fd1); read_and_print_one(fd2); printf(“\n”); } close(fd1); close(fd2); return 0; }

17 Carnegie Mellon I/O Consider the following code assuming all system calls to read() and write() are atomic of each other. foo.txt = “ABCDEFG” Determine 1. The output of the program. “AABCBCD” 1. The final contents of foo.txt. “ABCDEFG”

18 Carnegie Mellon Concurrent Processes Assume for the following program that: 1. All processes run to completion and no system calls fail. 2. printf() is atomic and calls fflush(stdout) after printing. 3. Logical operators such as && evaluate their operands left to right and only evaluate the smallest number of operands to determine the result.

19 Carnegie Mellon Concurrent Processes int main(){ int counter = 0; int pid; if( !(pid = fork()) ){ while( (counter < 2) && (pid = fork()) ){ counter++; printf(“%d”, counter); } if( counter > 0 ){ printf(“%d”, counter); } if(pid){ waitpid(pid, NULL, 0); counter = counter << 1; printf(“%d”, counter); }

20 Carnegie Mellon Concurrent Processes For the above code determine list all possible outputs.

21 Carnegie Mellon Concurrent Processes For the above code determine list all possible outputs

22 Carnegie Mellon Stack Discipline Consider the follwing C code (compiled on a 32-bit machine): void foo(char * str, int a){ int buf[2]; a = a; //pacify gcc strcpy((char *) buf, str); } /* the base pointer for the stack frame caller() is 0xffffd3e8 void caller() { foo(“123456”, oxdeadbeef); }

23 Carnegie Mellon Stack Discipline Here is the corresponding machine code on a 32-bit Linux machine: c8 : c8 :push%ebp c8 :mov%esp, %ebp c8 :sub$0x18, %esp c8 :lea-0x8(%ebp), %eax c8 :mov0x8(%ebp), %eax c8 :mov %eax, 0x4(%esp) c8 :mov%edx, (%esp) c8 :call0x80482c c8 :leave c8 :ret c8 : c8 :push%ebp c8 :mov%esp, %ebp c8 :sub$0x8, %esp c8 :movl$0xdeadbeef, 0x4(%esp) c8 :movl$0x80484d0, (%esp) c8 :call0x80483c c8 :leave c8 :ret

24 Carnegie Mellon Stack Discipline: At what address is the string “ ” stored (before strcpy)? Why doesn’t ret take an address to return to like jmp? Fill in the hex values of buf[0]…buf[4]. Will a function that calls caller() notice any corruption?

25 Carnegie Mellon Stack Discipline: At what address is the string “ ” stored (before strcpy)? 0x80484d0 Why doesn’t ret take an address to return to like jmp? ret gets return address from top of stack Fill in the hex values of buf[0]…buf[4]. 0x , 0x , 0xffffd3e8, 0x080483fc, 0x080484d0 Will a function that calls caller() notice any corruption? No segfault. " " is only 8 bytes including '\0', and int[2] can store 8 bytes.

26 Carnegie Mellon Questions?