Domains of protection
Domains of protection
Recorded by Dr. Krithika L.B. Slot m5-domains
Least privilege, protection domains and domain switching (setuid, MULTICS rings), the access matrix and its rights, and implementing it with access lists, capability lists and lock–key schemes.
By the end of this session you should be able to:
Protection is the set of mechanisms that control the access of processes and users to the resources of a computer system. It prevents malicious or mistaken misuse, and it limits the damage a faulty component can do. Two guiding principles:
Give programs, users and systems just enough privilege to perform their tasks — like a hotel key card that opens only your room and only for your stay. A bug or attack then does limited damage.
At any time a process should be able to access only those resources it currently needs to complete its task.
Remember the policy–mechanism separation of Session 1.4: protection provides mechanisms; who may access what is a policy set by designers, administrators and users.
A computer system is a collection of processes and objects — hardware objects (CPU, memory, printers, disks) and software objects (files, programs, semaphores). Each object has a unique name and a set of operations.
A protection domain is a set of access rights, each an ordered pair <object-name, rights-set>, e.g. <file F, {read, write}>. A process executes within a domain; domains may share rights. The association between a process and a domain can be static (fixed for the process's life) or dynamic (the process can switch domains).
Domains may overlap: here O2 appears in D1 and D2 with different rights.
UNIX: objects accessible depend on the user ID; switching domain = changing user (e.g. login, su).
Each process is a domain; switching = sending a message to another process.
Each procedure's local variables form a domain; switching happens on a procedure call.
The passwd program must write /etc/shadow, which ordinary users cannot touch. Its file has the
setuid bit: when executed, the process temporarily runs with the owner's (root's) user ID — a controlled domain switch.
$ ls -l /usr/bin/passwd /etc/shadow
-rwsr-xr-x 1 root root 59976 Feb 6 /usr/bin/passwd # 's' = setuid
-rw-r----- 1 root shadow 1532 Mar 12 /etc/shadowMULTICS organised domains as concentric rings 0…7: ring 0 (kernel) has the most privileges; a process in ring i can access ring j ≥ i freely, and must use a controlled gate to call into an inner ring. The x86 rings of Session 1.3 descend from this idea.
Protection can be modelled abstractly as a matrix: rows = domains, columns = objects, and entry
access(i, j) = the set of operations a process in domain Di may invoke on object Oj.
| domain \ object | F1 | F2 | F3 | printer |
|---|---|---|---|---|
| D1 | read | read | ||
| D2 | ||||
| D3 | read | execute | ||
| D4 | read, write | read, write |
A process in D4 may read and write F1 and F3; a process in D2 may only print. The matrix separates mechanism (the OS checks every access against it) from policy (who fills in the entries).
Domains as columns too: switch ∈ access(i, j) lets a process move from Di to Dj.
read* in a column lets the holder copy “read” to another domain in the same column — transfer (the original loses it) or limited copy (without the *).
The owner of an object can add or remove any right in that object's column.
control ∈ access(i, j) (j a domain) lets Di remove rights from Dj's row.
The matrix is large and sparse, so it is never stored directly.
A list of triples <domain, object, rights-set>. Simple, but the table is huge (cannot stay in memory) and grouping is hard — a file readable by everyone needs an entry for every domain.
Store each column with its object: object → list of <domain, rights>. Extend with a default set. This is how files are protected: UNIX rwx bits (owner/group/others) are a compressed access list; Windows and Linux ACLs are full lists.
Store each row with its domain: domain → list of <object, rights> called capabilities. Possessing the capability is proof of the right to access. Capabilities must be protected — kept by the kernel or tagged in hardware — so a process cannot forge them.
A compromise: each object has a list of locks, each domain a list of keys; access is allowed if a key matches a lock. Keys can be passed between domains; revoking = changing a lock.
Real systems combine them: the access list is checked once at open(), which then returns a capability — the file descriptor (Session 4.7) — used for every later read/write without re-checking.
| Access list (column) | Capability list (row) | |
|---|---|---|
| Answers easily | “Who can access this object?” | “What can this domain access?” |
| Check cost | Search the list on every access | Just present the capability |
| Revocation | Easy — edit the list | Hard — capabilities are scattered |
| Examples | UNIX rwx, ACLs | File descriptors, Hydra, CAP, Linux capabilities |
Revoking access may need to be immediate or delayed, selective or general, partial or total, temporary or permanent. With access lists it is easy; with capabilities the options are reacquisition, back-pointers, indirection through a global table, or keys that can be changed.
A capability-based OS (CMU) with a fixed set of rights plus user-defined rights interpreted by subsystems, and rights amplification for trusted procedures.
Hardware-supported data capabilities and software capabilities interpreted by protected procedures.
Root's all-powerful privilege is split into ~40 capabilities (CAP_NET_BIND_SERVICE, CAP_SYS_TIME…) so a program gets only what it needs — least privilege in practice. Try getcap /usr/bin/ping.
Domains of protection
Recorded by Dr. Krithika L.B. Slot m5-domains
Access matrix and capabilities
Recorded by Dr. Krithika L.B. Slot m5-access-matrix
Work through these in order after the lecture — each one expands a part of the notes with diagrams, hover notes and a quick check.
Answer each question in your own words first, then reveal the model answer.
Revealed 0No — D3 has only read on F2.
Access lists (one list per object).
Capabilities are distributed among many domains; they must all be found and invalidated, whereas an access list is in one place.
It lets an ordinary user's process temporarily run with root's privileges to update /etc/shadow — a controlled domain switch.
The domain has read and may copy the read right to other domains (in that object's column).
Protection isolates processes within one OS. Virtualization goes further: it isolates whole operating systems from each other on one machine.
Continue to 5.5 — Virtual machines and hypervisors →