Protection, containers and Linux
Security begins with identity and page permissions, then extends to virtual machines, namespaces and cgroups. The host can show a process a restricted world and limit it to 50 ms of CPU in each 100 ms period. We will connect permissions, boot, introspection, limits, leaks, caches, zero-copy and io_uring.
#Section 45Permissions and privilege
Unix permission digits encode read as 4, write as 2 and execute as 1. 755 therefore gives the owner 7, group 5 and others 5. A privilege is authority to perform an operation such as changing protected mappings or binding a restricted resource. UID, GID and effective UID participate in permission checks; root has broad authority and therefore a large failure radius.
sudo changes the identity context for a command under policy. Setuid programs run with an effective identity that may differ from the invoking user, so their input handling must be strict. A backend should run with only the files, ports and devices it needs.
Protection and access control
For a directory, execute permission means search or traversal rather than running its bytes as a program. Read lists names, and write participates in changing directory entries under the filesystem’s rules. File mode digits alone do not decide every access: credentials, mount policy and other access controls can also apply. The illustrated owner, group and other classes describe the declared basic permission model.
UID, GID and effective identity
Effective identity can grant more authority than the invoker has. Privileged helpers must constrain untrusted arguments. Reduce server authority while separately authorizing each user’s application operation.
#Section 46Virtual machines and containers
A virtual machine includes a guest OS above a hypervisor. A Type 1 hypervisor runs close to hardware, while a Type 2 runs through a host OS. Containers share the host kernel and isolate process views and resource budgets. Calling a container a lightweight VM hides the kernel-sharing difference.
Namespaces control what a process can see. Cgroups control how much it can use. Filesystem layers supply an initial tree, but the process still uses host kernel mechanisms for scheduling, memory and devices.
Hypervisors and containers
A VM exposes virtual CPUs, memory and devices to its guest kernel. The hypervisor maps those virtual resources onto host resources and establishes the isolation boundary. A guest scheduler makes decisions among guest tasks while a host layer still schedules the virtual CPU. Being runnable inside the guest does not imply receiving physical CPU time immediately.
A container image supplies files, not another kernel. Namespaces and quotas change separate contracts, so hidden processes do not imply reserved CPU or memory.
#Section 47Namespaces, cgroups and boot
PID namespaces can make a process see itself as PID 1 while the host assigns another PID. Network namespaces split interfaces and routes, mount namespaces change filesystem views, user namespaces map identities, and IPC or UTS namespaces isolate other kernel views. A cgroup is the resource boundary, not the visibility boundary.
Finch’s container has a 50 ms quota in a 100 ms period. Once it consumes its quota, the controller throttles it until the period permits more CPU. Boot passes control from firmware to bootloader, kernel, early userspace and PID 1, which starts services. On a systemd-based installation, systemd supplies that init role; another init implementation can supply the same lifecycle responsibility.
Namespaces and cgroups
CPU quota counts aggregate execution across the group. Several simultaneously running workers can exhaust it sooner in wall time; the allowance is not a fraction of every host core.
Boot process
An initramfs can supply early userspace needed to find and mount the intended root filesystem. The init system then starts services and collects adopted child status according to its policy. PID 1 has lifecycle duties distinct from an ordinary callback process. A container’s apparent PID 1 still needs deliberate signal forwarding and child collection; restricting its process view does not perform those duties automatically.
#Section 48Introspection, limits and leaks
/proc exposes process and kernel information as a pseudo-filesystem. /proc/<pid>/fd shows descriptor links, while strace displays system calls. ulimit and related limits cap resources such as open files. Finch has a descriptor limit of 1,024 and reserves 24, leaving 1,000 working slots in the declared model.
A memory leak retains useless allocations. A descriptor leak retains sockets or files until the process hits its limit. A thread leak retains execution resources and scheduling overhead. Diagnosis needs a count over time and a release path, not only a larger limit.
/proc, descriptor inspection, limits and syscall tracing. Orange marks the limit because it turns a leak into a hard failure.Linux process introspection and /proc
ps, top and htop expose different views of task activity; free and vmstat help distinguish memory and paging behavior. lsof connects open resources to processes. A syscall trace can reveal repeated would-block returns or an unexpected blocking operation, but its own collection cost and access permissions remain relevant. No single display converts a symptom into a cause without a timeline.
Resource limits and leaks
Compare resource counts at the same workload phase. Retained allocator capacity is not automatically a leak. Fix ownership and cleanup paths; raising a limit only postpones an unbounded lifetime problem.
#Section 49Caches, false sharing and fast I/O
Registers, caches, RAM and SSD trade capacity for latency. A cache line is the unit moved by cache coherence; Finch’s model uses 64 bytes. False sharing occurs when two threads update separate variables on one cache line, causing invalidations even though the variables are logically independent.
User-space networking can reduce copies or transitions through mechanisms such as sendfile, which can send file-backed data without copying it through an application buffer. io_uring uses submission and completion queues to submit operations and receive results. These interfaces reduce a particular dispatch cost; they do not remove storage latency or make blocking work safe in an event loop.
Cache hierarchy and false sharing
Temporal locality reuses recently accessed data; spatial locality accesses nearby bytes likely to share a fetched line. Finch’s illustrative 64-byte line can contain eight 8-byte counters. Placing different writers’ counters there can cause coherence invalidations despite logically independent variables. Padding or separating ownership can remove that sharing at a memory-footprint cost; it does not correct an actual race on the same counter.
User-space networking, zero-copy and io_uring
sendfile changes a copy path but still uses the kernel. io_uring changes submission and completion; DPDK-style paths change packet ownership. None removes every I/O cost or recovery duty.