Contrasting Linux Containers with Hardware Virtualization

Medium · Software Engineering Fundamentals · Software Engineer · Technical Screen

Prompt

Platform engineers building compute clusters routinely choose among bare-metal servers, hardware-virtualized guests (managed by Type 1 or Type 2 hypervisors), OS-level Linux containers, and blended sandboxing runtimes.

Walk through an end-to-end systems comparison contrasting Linux containers against hardware virtual machines. Compare how both models isolate processes, schedule CPUs, translate memory and I/O, defend against privilege escalation, handle cross-OS or cross-kernel-version workloads, and inspire modern microVM and syscall-interception runtimes.

Scope & Expectations

  • Isolation boundary & low-level mechanisms: Contrast sharing a single host Linux kernel (built from namespaces, cgroups, capabilities, seccomp-bpf, LSM policies, and pivot_root) against running separate guest kernels atop Type 1/Type 2 hypervisors (using hardware CPU virtualization, nested page tables, and virtualized devices).
  • Performance, memory, and scheduling: Compare per-instance RAM, boot times, storage/network data paths, and direct host thread scheduling (CFS/EEVDF) versus two-layer guest-plus-host vCPU scheduling.
  • Threat model & compatibility: Weigh the shared-syscall attack surface and practical container breakout paths against hypervisor isolation, and compare guest OS freedom on VMs with Linux kernel ABI constraints when container binaries encounter older host kernels.
  • Sandboxed & microVM designs: Position hybrid runtimes (such as stripped-down microVMs, VM-per-pod runtimes, and user-space application kernels) along the isolation-versus-overhead spectrum.

Step-by-step walkthrough

  1. Start with the core boundary: shared kernel vs. virtual hardware

    Every difference between a container and a virtual machine comes from where the isolation boundary sits. In an operating system, the kernel is the privileged core program that directly controls hardware (CPU, RAM, disks, network cards), while user space is the unprivileged mode where ordinary applications run and must ask the kernel for hardware services via system calls (controlled entry points into the kernel).

    • Linux containers are ordinary host processes running in user space that share the single host Linux kernel. Isolation comes from kernel visibility filters and resource limits wrapped around a process tree.
    • Virtual machines (VMs) run a complete guest operating system with its own guest kernel on top of simulated hardware managed by a hypervisor — a thin privileged software layer that slices physical CPU, memory, and devices across multiple guests.
              Linux Containers                         Virtual Machines
    +----------------+----------------+     +------------------+------------------+
    | App A + libs   | App B + libs   |     | App A + libs     | App B + libs     |
    | (user space)   | (user space)   |     | Guest Kernel A   | Guest Kernel B   |
    +----------------+----------------+     | Virtual Hardware | Virtual Hardware |
    | Container runtime (containerd / |     +------------------+------------------+
    | runc sets kernel boundaries)    |     | Hypervisor (KVM + VMM like QEMU or  |
    +---------------------------------+     | Firecracker, Xen, VMware ESXi)      |
    |     ONE Host Linux Kernel       |     +-------------------------------------+
    +---------------------------------+     |          Physical Hardware          |
    |        Physical Hardware        |     +-------------------------------------+
    +---------------------------------+
    

    Hypervisors are traditionally grouped into two architectures:

    • Type 1 (bare-metal): runs directly on physical hardware with no general-purpose host OS underneath (examples: VMware ESXi, Xen, Microsoft Hyper-V).
    • Type 2 (hosted): runs as an ordinary application on top of an existing desktop or server OS (examples: VirtualBox, VMware Workstation).
    • Linux KVM (Kernel-based Virtual Machine) blends the best of both: KVM is a kernel module inside Linux that turns the host kernel itself into a Type-1-style hypervisor for CPU and memory, while a companion user-space process called a Virtual Machine Monitor (VMM) (such as QEMU, AWS Firecracker, or Cloud Hypervisor) sets up guest memory and emulates I/O devices.
  2. How Linux builds a container from kernel primitives

    Linux has no single create_container() system call. Instead, an OCI runtime like runc spawns a child process, configures six orthogonal kernel mechanisms on it, and finally calls execve() (the system call that replaces the current process's program with the container's target binary):

    • Namespaces (what the process can see): a namespace wraps a global kernel resource so processes inside see their own private view. Linux provides 8 namespaces:
      • pid: gives the container its own process ID numbering starting at PID 1.
      • net: gives it private network interfaces, IP addresses, routing tables, and firewall rules.
      • mnt: gives it an independent list of filesystem mounts.
      • uts: isolates the hostname and domain name.
      • ipc: isolates shared-memory segments and POSIX message queues.
      • user: maps root (UID 0) inside the container to an unprivileged UID (such as 100000) on the host.
      • cgroup: hides the host's full control-group directory tree.
      • time (since Linux 5.6): allows per-container monotonic and boot-time clock offsets.
    • Control groups / cgroups (how much the process can use): namespaces only restrict visibility, never resource usage. Control groups (cgroups) meter and cap CPU shares/quotas (cpu.weight, cpu.max), RAM (memory.max, memory.high), disk I/O bandwidth, and maximum process count (pids.max, stopping fork bombs). Older cgroups v1 used separate hierarchies per resource; modern cgroups v2 (non-experimental since Linux 4.5) unifies all controllers into one tree.
    • Capabilities (which root powers survive): Linux splits omnipotent root privilege into roughly 40 discrete capabilities. Container runtimes grant only a small subset (like CAP_NET_BIND_SERVICE to bind low ports or CAP_CHOWN to change file ownership) and drop dangerous ones like CAP_SYS_ADMIN (catch-all admin rights) and CAP_SYS_MODULE (loading kernel drivers).
    • seccomp-bpf (which system calls are reachable): seccomp-bpf attaches a small Berkeley Packet Filter program to the process that inspects every system call number and raw arguments upon kernel entry. Docker's default profile blocks roughly 44 of Linux's 300+ system calls (such as reboot, kexec_load, and init_module).
    • Linux Security Modules — AppArmor / SELinux (mandatory access control): an LSM enforces kernel-level security labels or path rules on files, sockets, and /proc entries even if a process holds UID 0.
    • pivot_root instead of chroot: chroot only changes where / resolves for path lookups without isolating the mount table — a privileged process holding an open file descriptor outside the new root can walk .. and escape. Instead, runtimes create a private mnt namespace, call pivot_root to swap the root mount to the container's image directory, and unmount the old host root entirely.

    You can build a toy container from the shell with unshare to see that no hypervisor is involved:

    $ sudo unshare --pid --fork --mount-proc --uts --net bash
    # hostname demo-box
    # ps -ef          -> bash appears as PID 1; host processes are invisible
    # ip link         -> only an isolated, down loopback interface ("lo") exists
    
  3. How a hypervisor isolates a VM: vCPU, nested paging, and virtual I/O

    Unlike a container runtime, a hypervisor must virtualize CPU execution, physical memory translation, and hardware devices.

    • Virtual CPU (vCPU) and hardware exits: Intel VT-x and AMD AMD-V add a dedicated hardware execution mode for guests (VMX non-root on Intel) alongside the hypervisor's VMX root mode. Inside VMX non-root, both guest applications (ring 3) and the guest kernel (ring 0) execute instructions directly on the physical CPU at native speed — no software instruction translation needed. Only sensitive events (accessing an emulated device register, missing in host memory mappings, or executing specific control instructions) trigger a VM exit: the CPU saves guest register state into a hardware VMCS (Virtual Machine Control Structure) and jumps into the hypervisor to handle the event before resuming the guest (VM entry). In KVM, each vCPU is simply a normal Linux thread on the host looping on ioctl(KVM_RUN).
    • Memory virtualization (MMU and EPT/NPT): an MMU (Memory Management Unit) uses multi-level page tables in RAM to translate virtual addresses into physical RAM addresses, caching recent translations in the TLB (Translation Lookaside Buffer). A VM adds a second layer: the guest kernel translates Guest Virtual -> Guest Physical, and the hypervisor translates Guest Physical -> Host Physical.
      • Legacy shadow page tables: the hypervisor write-protected guest page tables in software and trapped every update to maintain a combined table — very slow for fork-heavy workloads.
      • Hardware nested paging (Intel EPT / AMD NPT): the CPU's page-table walker traverses both trees automatically in hardware without VM exits on page-table edits. However, when the TLB and paging caches miss completely, every single level of the guest page table requires a full walk of the host EPT first:
    4-level Guest Table + 4-level Host EPT (worst-case cold TLB miss):
      Guest Level 4 addr -> [4 Host EPT reads] + 1 Guest L4 read =  5 memory reads
      Guest Level 3 addr -> [4 Host EPT reads] + 1 Guest L3 read =  5 memory reads
      Guest Level 2 addr -> [4 Host EPT reads] + 1 Guest L2 read =  5 memory reads
      Guest Level 1 addr -> [4 Host EPT reads] + 1 Guest L1 read =  5 memory reads
      Final data page    -> [4 Host EPT reads]                   =  4 memory reads
                                                           Total = 24 page-table reads
    
    def nested_page_walk_lookups(guest_levels: int, host_levels: int) -> int:
        # Translating each guest page-table level requires a full host walk
        # (host_levels reads) before reading the 1 guest entry itself.
        per_guest_level = host_levels + 1
        # Once the final guest-physical data page is known, translating its
        # address to host-physical RAM takes one final host walk.
        return guest_levels * per_guest_level + host_levels
    
    
    assert nested_page_walk_lookups(4, 4) == 24   # vs. 4 reads in a container / bare metal
    assert nested_page_walk_lookups(5, 5) == 35   # 5-level paging on both guest and host
    

    Backing guest RAM with huge pages (2 MiB or 1 GiB blocks instead of 4 KiB pages) reduces host EPT levels and sharply increases TLB hit rates.

    • Device I/O virtualization: emulating old physical hardware (like an Intel e1000 NIC) causes a slow VM exit on every register write. Instead, modern VMs use paravirtual virtio drivers — the guest knows it is virtualized and batches requests into shared-memory ring buffers with one notification per batch. vhost moves ring processing directly into a host kernel thread (skipping user-space VMM hops), and VFIO / SR-IOV passthrough assigns a slice of a physical NIC or NVMe drive directly to the guest at near-native speed, policed by the IOMMU (Input-Output Memory Management Unit, hardware that restricts which host RAM addresses a PCIe device can read or write via DMA).
  4. Resource overhead and CPU scheduling: one scheduler vs. double scheduling

    Because containers skip the guest kernel and virtual hardware layer, every operational metric shifts:

    Dimension Linux Container Virtual Machine
    Memory Only the app's own memory; containers reading the same base image files share one host page cache (RAM cache of disk blocks). Extra guest kernel + guest daemons + separate guest page cache per VM (same file can be cached twice unless direct I/O is used).
    Startup latency Milliseconds to tens of milliseconds once the image is local (clone + namespaces + mounts + execve). Network image pulls dominate cold starts. Full OS boot (firmware -> bootloader -> kernel -> systemd) takes seconds; stripped microVMs reach ~100–200 ms.
    Disk I/O OverlayFS (union filesystem stacking a writable top layer over read-only image layers): reads are native, but the first 1-byte edit to a lower-layer file triggers a copy-up of that whole file. Mounted volumes bypass OverlayFS. Guest FS -> virtio-blk -> vhost / VMM -> host block device or image file (two storage stacks unless raw passthrough is used).
    Network I/O Virtual Ethernet (veth) cable pair -> host Linux bridge -> iptables / nftables / eBPF NAT (~microseconds overhead; --network=host removes it completely). Guest NIC driver -> virtio-net -> vhost-net -> host tap device -> bridge (or SR-IOV hardware passthrough for near-bare-metal latency).

    Worked memory calculation: suppose we deploy 40 microservices, each needing a 200 MiB heap/working set: - As 40 containers: 40 × 200 MiB = 8,000 MiB (≈ 7.8 GiB), plus ~5–10 MiB per container shim (containerd-shim), sharing one host kernel and page cache. - As 40 separate small VMs (assuming 250 MiB per VM for guest kernel, init daemons, and guest page cache): 40 × (200 + 250) MiB = 18,000 MiB (≈ 17.6 GiB) — more than 2× the RAM.

    CPU scheduling — one scheduler vs. two: - Containers: every thread inside a container is scheduled directly by the single host Linux scheduler — historically CFS (Completely Fair Scheduler) and since Linux 6.6 EEVDF (Earliest Eligible Virtual Deadline First). When a thread blocks on a mutex or socket, the host kernel immediately schedules another runnable thread. The main container pitfall is cpu.max bandwidth throttling: setting cpu.max = 200000 100000 grants 200 ms of CPU quota per 100 ms wall-clock window ("2 cores"). If an 8-thread Java/Go service wakes up on an 8-core machine, all 8 threads run in parallel and burn 200 ms / 8 = 25 ms of wall time, leaving the container frozen (throttled) for the remaining 75 ms of the window and spiking p99 tail latency. - VMs (double scheduling): the guest kernel schedules guest threads onto vCPUs, while the host kernel independently schedules vCPU threads onto physical cores without knowing what the guest is doing. If vCPU 0 grabs a guest kernel spinlock (a busy-wait lock held for microseconds) and the host preempts vCPU 0's thread, vCPU 1 wastes its entire time slice spinning uselessly waiting for a sleeping lock holder (lock-holder preemption). Hypervisors mitigate this via pause-loop exiting (hardware detects excessive PAUSE instructions in spin loops and triggers a VM exit), paravirtual spinlocks (halting waiters cleanly), and vCPU pinning (dedicating physical cores 1-to-1 for low-latency trading or database VMs).

  5. Security boundary, attack surface, and escape vectors

    Security engineers compare how wide and complex the boundary interface is:

    • Shared-kernel surface (containers): every container directly invokes the host Linux kernel across 300+ system calls, complex filesystem parsers, networking socket options, ioctl handlers, /proc, and /sys. One exploitable privilege-escalation bug in any reachable kernel path compromises the host and every other container on that machine.
      • Misconfigurations (most frequent in practice): --privileged (grants all capabilities, disables seccomp/LSM, exposes host /dev block devices so the host disk can be mounted directly), granting CAP_SYS_ADMIN, bind-mounting /var/run/docker.sock (which gives root-equivalent control over the Docker daemon), or mounting host /.
      • Writable /proc and /sys hooks: if poorly isolated, files like /proc/sys/kernel/core_pattern or cgroups v1 release_agent (CVE-2022-0492) tell the host kernel to execute an attacker-chosen binary as host root.
      • Unmapped root: without a user namespace, UID 0 inside the container is UID 0 on the host, magnifying any path-traversal or leaked-file-descriptor bug.
      • Runtime and kernel CVEs: runc /proc/self/exe overwrite (CVE-2019-5736), leaked host directory descriptors (CVE-2024-21626), and kernel bugs like Dirty COW (CVE-2016-5195) or Dirty Pipe (CVE-2022-0847).
    • Hypervisor boundary (VMs): exploiting a bug inside the guest kernel only compromises that single VM. Escaping to the host requires exploiting the hypervisor's VM-exit handlers or its device-emulation code — a vastly smaller code surface than the entire Linux syscall ABI. Still, VMs are not magically unbreakable: device-emulator bugs have happened (such as QEMU's floppy-controller bug VENOM, CVE-2015-3456), and CPU side-channel attacks (Spectre, L1TF, MDS) can leak secrets across VMs sharing SMT (Simultaneous Multithreading / Hyper-Threading) sibling threads on the same physical core, which is why strict multi-tenant clouds disable cross-tenant core sharing.
  6. OS compatibility and kernel ABI mismatches

    An ABI (Application Binary Interface) is the binary-level contract between compiled user-space programs and the kernel: exact system call numbers, CPU register conventions, error codes, and struct memory layouts.

    • VMs virtualize hardware (ISA level): any operating system compiled for the host CPU architecture (x86-64 or ARM64) runs unmodified — Windows Server, FreeBSD, an ancient Linux 3.10 kernel, or a bleeding-edge Linux 6.12 kernel can all run side by side on one Linux KVM host. (Running a different CPU architecture, like ARM64 on x86-64, requires full software instruction translation like QEMU TCG, which is much slower.)
    • Containers package user space only (ABI level): a container image bundles binaries and C libraries (glibc for Ubuntu/Debian, musl for Alpine), never a kernel. Therefore, Linux containers require a Linux kernel, Windows containers require a Windows kernel, and Docker Desktop on macOS/Windows transparently runs a lightweight Linux VM in the background.

    Linux preserves backward ABI compatibility (old container images work fine on newer host kernels), so compatibility failures mainly happen when running a newer user-space image on an older host kernel:

    • Missing system calls or flags: calling a newer syscall on an older kernel (for example, io_uring_setup added in Linux 5.1, clone3 added in 5.3, or openat2 added in 5.6, when running on a Linux 4.19 host) returns -ENOSYS ("Function not implemented"), while unknown flags return -EINVAL or -EOPNOTSUPP.
    • Fallback traps with seccomp: modern C libraries probe gracefully — glibc 2.34+ tries clone3() and falls back to clone() when it sees ENOSYS. However, older Docker seccomp profiles returned EPERM ("Operation not permitted") for unknown syscalls instead of ENOSYS, tricking glibc into failing outright instead of falling back until runtimes updated their default profiles.
    • Hard floor and kernel modules: if the host kernel is older than the minimum version compiled into glibc, every binary immediately aborts with FATAL: kernel too old. Likewise, unprivileged containers cannot load missing kernel modules (modprobe for filesystems, WireGuard, or custom netfilter modules) — the host must supply them.
  7. Hybrid architectures: microVMs and sandboxed runtimes

    Modern cloud platforms preserve the developer ergonomics of OCI container images while replacing or hardening the shared-kernel boundary:

    Fastest / Shared Kernel  <----------------------->  Strongest Hardware Boundary
      [ Plain runc ]  ->  [ gVisor ]  ->  [ Firecracker / Kata ]  ->  [ Full QEMU VM ]
      1 host kernel      User-space       Minimal VMM + dedicated     Legacy devices +
      for all pods       Go kernel        guest kernel per pod/fn     full OS per VM
    
    Architecture How Isolation Works Key Trade-off
    Containers in Node VMs (standard cloud Kubernetes) Each cluster node is a VM; pods on the same node are runc containers sharing that node's kernel. Fast pod startup, but untrusted tenants must be separated onto dedicated node pools (VM-per-tenant, not VM-per-pod).
    AWS Firecracker (used by Lambda & Fargate) Minimal KVM VMM written in Rust that strips legacy PC hardware (no BIOS, PCI, USB, or VGA; only virtio net/block/vsock/balloon and serial). Boots a minimal Linux guest kernel to user space in ~125 ms with < 5 MiB VMM memory overhead per microVM, but cannot do PCI/GPU passthrough or run Windows.
    Cloud Hypervisor Rust KVM VMM built on rust-vmm crates; keeps modern virtio, PCI hotplug, and VFIO device passthrough. Supports GPUs and Windows/Linux cloud workloads with a much smaller codebase than QEMU, at slightly larger surface than Firecracker.
    Kata Containers Runs one lightweight microVM (via Firecracker, Cloud Hypervisor, or QEMU) per Kubernetes pod; an in-guest kata-agent spawns the containers inside. Drop-in Kubernetes RuntimeClass compatibility with hardware VM isolation per pod, trading extra per-pod RAM and virtio-fs filesystem overhead.
    Google gVisor (runsc) Intercepts container syscalls (using systrap or KVM) and handles them inside the Sentry — a user-space kernel written in memory-safe Go that invokes only ~70 allowlisted host syscalls. Runs anywhere without needing nested hardware virtualization, but adds noticeable overhead to syscall-heavy and file-I/O-heavy apps and does not implement 100% of obscure Linux syscalls or /proc files.

Intuition & how it works

Think of Linux containers like locked suites inside one shared office building where every tenant relies on the same central plumbing, electrical grid, and building superintendent — that shared infrastructure is the single host Linux kernel (the privileged core program controlling hardware). By contrast, virtual machines (VMs) are separate detached buildings sitting on fenced lots managed by a land developer called a hypervisor (software that carves physical CPU, RAM, and devices into simulated hardware), so every VM runs its own independent plumbing and superintendent (guest kernel).

Beginners often call a container a "lightweight VM," assuming it boots a miniature operating system. That mental model fails in both directions: because containers share one kernel, they cannot run a non-Linux OS, cannot use newer kernel calls missing on the host, and expose a 300+-syscall shared attack surface where one kernel bug compromises every neighbor; conversely, deploying full VMs for every small service duplicates gigabytes of guest kernels, boots much slower, and adds nested memory-translation and double-CPU-scheduling overhead.

Trace deploying 4 small microservices, each needing 200 MiB of application RAM, and touching an uncached memory page:

  1. As 4 containers: the runtime (runc) creates isolated namespaces (private views of process IDs, mounts, and networking) and cgroups (resource caps) in tens of milliseconds. Total RAM is roughly 4 × 200 MiB = 800 MiB sharing one host page cache, and a cold TLB (CPU address-translation cache) miss walks 4 host page-table levels before reading RAM.
  2. As 4 traditional VMs (with ~250 MiB per VM for guest kernel, daemons, and duplicate cache): each VM boots its own kernel in seconds, consumes 4 × (200 + 250) = 1,800 MiB total RAM, and a cold TLB miss with 4-level guest + 4-level host nested page tables walks up to 4 × (4 + 1) + 4 = 24 page-table entries — buying hardware-enforced isolation so a guest kernel crash or exploit stays trapped inside that single VM.

Key points

  • Boundary placement drives everything: containers isolate ordinary host processes using six Linux kernel mechanisms — namespaces (visibility), cgroups (resource quotas), capabilities (fine-grained root privileges), seccomp-bpf (syscall filtering), LSMs like AppArmor/SELinux (mandatory access rules), and pivot_root (swapping the root mount). VMs isolate whole guest kernels behind hardware CPU virtualization (Intel VT-x / AMD-V) and nested page tables (EPT / NPT).
  • Performance and memory: containers pay near-zero CPU/syscall overhead and share one host page cache; VMs pay per-guest kernel memory, longer boot times, nested TLB-miss page walks (mitigated by 2 MiB / 1 GiB huge pages), and virtualized storage/network hops (minimized by paravirtual virtio rings, in-kernel vhost, or IOMMU-guarded PCIe passthrough).
  • Single vs. double CPU scheduling: container threads are scheduled directly by the host kernel's fair scheduler (CFS, or EEVDF since Linux 6.6), though tight cpu.max quotas can throttle multi-threaded bursts; VM vCPUs are scheduled twice (guest scheduler on vCPUs, host scheduler on physical cores), risking lock-holder preemption when a vCPU holding a guest spinlock gets descheduled.
  • Security vs. compatibility: containers expose the broad host syscall ABI (escapes stem from --privileged misconfigurations, mounted docker.sock, writable /proc or /sys files, or kernel CVEs) and require host kernel ABI compatibility; VMs narrow the host boundary to VM-exit handlers and virtual devices while running any OS (Windows, BSD, older/newer Linux) built for the CPU architecture.
  • Hybrid runtimes bridge the gap: AWS Firecracker and Kata Containers place a stripped-down microVM boundary (~125 ms boot, < 5 MiB VMM overhead) around each function or pod, while Google gVisor intercepts syscalls in a memory-safe Go user-space kernel (Sentry) without requiring hardware virtualization.

Common mistakes

  • Calling containers "lightweight VMs": containers never boot or contain a kernel; confusing the two leads to wrong answers on security escapes and OS compatibility.
  • Saying namespaces limit CPU or RAM: namespaces only hide identifiers (PID, NET, MNT); resource limits come exclusively from cgroups.
  • Claiming every system call inside a VM traps to the hypervisor: under VT-x / AMD-V, guest system calls go directly from guest user space to the guest kernel at native speed; VM exits happen only on sensitive operations like emulated device access or host EPT page faults.
  • Treating chroot or unmapped container root as secure: chroot does not isolate mount tables, and without a user namespace, UID 0 inside a container is UID 0 on the host.
  • Claiming VMs are 100% unbreakable: device-emulation bugs (like QEMU's VENOM) and cross-core CPU side channels (Spectre, L1TF across Hyper-Threading siblings) still require minimal VMMs and disabling cross-tenant core sharing.
  • Ignoring image pull times and cpu.max throttling: local container creation takes milliseconds, but pulling multi-gigabyte images dominates cold starts, and multi-threaded apps hit tail-latency spikes when burning through a cgroup CPU quota early in a 100 ms period.

Follow-up questions

  • Trace the execution path and latency difference between a system call issued in an ordinary Linux container versus one issued inside a hardware-virtualized guest. Inside a standard container, executing the syscall instruction transitions directly into the single host Linux kernel, adding only nanoseconds to run the seccomp-bpf filter (an in-kernel syscall allowlist program) and LSM security hooks. Inside a hardware-assisted VM, a pure-CPU syscall like getpid() also transitions at near-native speed straight into the guest kernel without triggering a VM exit (a hardware trap out to the hypervisor). Latency diverges when the syscall performs real I/O: an uncached read() in a VM traverses the guest filesystem, writes a virtio shared-memory ring buffer, rings a doorbell that triggers a VM exit (signaling an ioeventfd event descriptor to a host vhost kernel thread or VMM), runs through the host kernel's storage stack, and injects a virtual completion interrupt back into the guest — traversing two kernels and at least one exit unless polled I/O is configured.
  • Why are default OCI containers inadequate for running hostile third-party code on shared nodes, and how would you harden the runtime stack? Plain runc containers are not sufficient for hostile multi-tenant code because every container on a node shares one Linux kernel, meaning a single kernel zero-day reachable through allowed syscalls compromises every tenant on that machine. First, place a stronger isolation boundary per pod or tenant using a Kubernetes RuntimeClass (a pod setting that selects an alternative container runtime) backed by Kata Containers / Firecracker microVMs or gVisor, and isolate tenants onto dedicated VM node pools with SMT (Hyper-Threading) core sharing disabled against CPU side channels. Second, enforce defense-in-depth inside the workload: run as non-root with user namespaces, drop all Linux capabilities, set allowPrivilegeEscalation: false, mount a read-only root filesystem, apply strict seccomp and AppArmor/SELinux profiles, and ban hostPath, hostNetwork, and runtime sockets. Third, cap blast radius with cgroups v2 memory/CPU/pids.max limits, default-deny network policies blocking cloud metadata IPs (169.254.169.254), and runtime syscall anomaly monitoring.
  • What memory-accounting and OOM-handling problems in cgroups v1 does the unified cgroups v2 hierarchy solve? In cgroups v1, CPU, memory, and block I/O lived in separate directory trees, so asynchronous disk writeback of dirty cache pages could not be billed back to the container that dirtied them, and kernel memory (kmem) had fragile separate accounting. cgroups v2 unifies all controllers into one hierarchy — enabling accurate cgroup-aware writeback and unified user + kernel slab/socket memory accounting — and replaces blunt limits with graded thresholds: memory.low / memory.min protect critical working sets, memory.high throttles allocations and triggers aggressive page reclaim before anything dies, and memory.max acts as the hard ceiling where the OOM killer (the kernel routine that terminates processes when memory is exhausted) steps in. Finally, cgroups v2 exposes PSI (memory.pressure, Pressure Stall Information measuring the percentage of time tasks stall waiting for memory reclaim) for proactive user-space daemons like systemd-oomd, and adds memory.oom.group = 1 so multi-process containers are terminated cleanly as an atomic unit instead of left running in a half-broken state after one worker process dies.

Follow-up questions

Similar questions

More Deshaw interview questions

All 7 Deshaw questions →