Worksheet 4
Video Lecture
eLearn link: Exceptions
After the lecture, you will learn the following concept:
- CPU modes
- What is system call and how is it different from function call
- Address space and kernel protection
- 2 system programming principles (from 2 perspectives)
- Time sharing
- CPU exceptions: trap, interrupt, fault, abort
Readings
Hands-on Lab
- Linking (this lab last for two weeks, concept check: Sept. 24): explore how executable is built and distributed through library
- Address Space
- Path Traversal
- Error Checking: The code is in the same repository of the Path Traversal demo. Here are some common errors that we might need to deal with: Wikipedia.
Learning Goals
Sept. 24 Quiz will check:
- I understand the difference between static and shared library, the advantage and disadvtange of each approach, and in which scenario they are used. (Linking)
- I understand the role of CPU modes (user vs. kernel) and why only trusted code can run in kernel mode.
- I understand the purpose of system calls
- I understand what an address space is: stack, heap, code. (Address Space)
- I understand the step-by-step process of a system call (saving registers, trapping to the kernel, switching to the kernel stack, validating arguments, running kernel functions, and returning to user mode). And how system call is different from function call
- I understand what CPU exceptions are (trap, interrupt, fault, abort)
- I understand why context switching is necessary for CPU time sharing
- I understand the difference between fast and slow system calls
- I understand how vDSO can bypass mode switching to improve performance.
- I understand the importance of input validation for platform providers and error checking for platform users in system programming.
- I understand why running as root is dangerous if privileges are not dropped and how this leads to privilege escalation vulnerabilities. (Path Traversal)
- I understand the Principle of Least Privilege and how dropping privileges prevents unintended access to protected files. (Path Traversal)