Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions W12D2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# W12D2

## Distributed Shared Memory

Q: Addressing

- Message
- packet
- document
- file (page)
- Shared Memory (OS does it)
- directory (translation)



#### DHT(Chord)

Background: distributed searching

Basic: any content $K_i = Hash(...)$

- machine $i$ has file A.mpg: $Hash(A.mpg) = 1$, then let machine 1 hold the information that A.mpg is owned by $i$
- query A.mpg: Hash = 1 $\to$ ask machine 1 for the owner $\to$ go to owner $i$

Challenge: some machine may be offline

- $succ(i)$: $i$'s next online machine
- finger table: for each online machine, maintain $succ$ of $s+2^k,k=0,1,2,...$ on machine $s$
- every time a machine becomes online: broadcast, other machines update finger table



#### Distributed Systems

- Chip: SoC (System on Chip)
- Board: SMP (Symmetric Pultiprocessing) recall: reentrant functions
- LAN: Cluster
- Internet: Grid $\to$ Cloud
38 changes: 38 additions & 0 deletions W4D2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# W4D2

## Memory Management

#### Concepts

- No Memory Abstraction
- reallocation (static/dynamic)
- swapping
- Virutal Memory
- need to run programs that are too large to fit in memory
- no explicit swapping -> OS does it
- Page Replacement Algorithm
- Optimal algorithm (based on the future)
- NRU (not recently used) algorithm
- Referenced bit and Modified bit
- class0: not R not M
- class 1: not R, M
- class 2: R, not M
- class 3: R and M
- FIFO algorithm
- Second-chance algorithm
- Clock algorithm
- optimize the queue: only the clock ptr needs to move
- LRU (least recently used) algorithm
- complex for hardware
- simulating LRU in software: aging algorithm
- Working set algorithm
- each process focus on a set of pages
- WSClock algorithm

##### Physical Memory Management

- Buddy System (UNIX)
- allocate $2^m$ continual physical pages(frames)
- free_areas[] (list head)
- buddy: $2k*2^n$ and $(2k+1)*2^n$
- used in Linux since 1970s. why efficient?
53 changes: 53 additions & 0 deletions W8D2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# W8D2

#### Buffer Overflow

- Architecture level mechanism: data area not executable (page table: DEP)

- Stack Canary

- compiler adds canary in stack and check whether canary is modified

- eg:

```c
foo() {
//compiler: add code to insert canary
char s[128];
get(s);
//compiler: add code to check canary
}
```



#### Code Reuse Attacks (Return to libc)

```c
system("/bin/sh");
=
fork();
execve("/bin/sh");
```

- use instructions in libc to build useful functions (including stack overflow)



#### Format String Attack

format string:

```c
printf("Hello, %s", name);
printf("%x add %x equals %x", a, b, c);
```

- if not enough args provided:
- compiler will reserve space for these args
- can be used to either leak information or modify registers



#### Back Doors