TL;DR: The CPU runs ordinary programs in an unprivileged mode that cannot touch hardware, page tables or other processes' memory; only the kernel runs privileged. A program asks for anything privileged through a system call: a controlled entry point where the CPU switches mode and jumps to kernel code chosen by the kernel, which must then validate every argument the program supplied, especially pointers. Because the kernel enforces isolation between all processes, a single kernel vulnerability can break all of it at once, which is why containers sharing a kernel are a weaker boundary than separate virtual machines.
How to approach it
Answer in three layers: what the hardware enforces, how a request crosses the boundary, and what the kernel must check on the far side. Then give the security consequence: what an attacker gains by crossing it and why the boundary matters to sandboxes and containers. Using "ring 0 and ring 3" is fine on x86, but say that the property is privilege mode, not the number.
A strong answer
Program
user mode, ring 3
syscall instruction
CPU switches mode
Kernel entry
chosen by the kernel
Validate args
copy, check, use
Privileged work
with kernel authority
Where it goes wrong
Unchecked pointers
- A user pointer aimed at kernel memory
- SMAP and SMEP stop the kernel touching user pages by accident
Double fetch
- Value checked, then re-read after another thread changed it
- Copy once into kernel memory, then validate
One kernel bug breaks all
- Every process and container on the machine shares this kernel
What the hardware enforces. The processor has at least two privilege levels. In user mode, privileged instructions (changing page tables, disabling interrupts, talking to devices directly) fault instead of running. Memory is reached through virtual addresses that the memory management unit translates using page tables the kernel controls, so a user process can only see the pages the kernel mapped for it. Kernel memory is mapped either not at all or as supervisor-only, so a user-mode read of it faults.
How a request crosses. A program that wants to open a file, send a packet or allocate memory places a system call number and arguments in registers and executes a dedicated instruction (syscall on x86-64, svc on ARM64). The CPU switches to kernel mode and jumps to an entry address the kernel registered at boot, not one the program chose. The kernel dispatches on the number, does the work with its own privileges, and returns to user mode with a result. Interrupts and faults enter the kernel the same controlled way.
What the kernel must distrust. Everything the caller passed is attacker-controlled input:
- Pointers. A program can pass the address of kernel memory, or of memory belonging to a different mapping, and ask the kernel to write there. The kernel copies through helpers (
copy_from_user,copy_to_userin Linux) that check the address range and handle faults. Hardware features such as SMAP and SMEP stop the kernel from accidentally reading user data or executing user pages while in kernel mode, which closes a classic class of exploits. - Time. User memory can change while the kernel is reading it. Reading a length, checking it, then reading it again is a double-fetch race; the kernel must copy once and use the copy.
- Objects and permissions. A file descriptor number must belong to this process, and the operation must be allowed for this process's credentials. Access checks happen here, at the moment of use.
Why it matters for security.
| If an attacker gets... | They can... |
|---|---|
| Code execution in a user process | Do what that process's user and permissions allow |
| A kernel bug reachable from that process | Rewrite credentials, read any memory, disable security modules, escape the container |
Every container on a host shares one kernel, so the kernel's system call surface is the container boundary. That is why sandboxes shrink it: seccomp filters block system calls a workload never needs, and gVisor puts a user-space kernel in front of the host so the real kernel sees a much smaller surface. A virtual machine adds a hypervisor boundary: a guest kernel compromise still leaves the attacker inside the guest.
One correction interviewers like to hear: running a program as administrator or root changes its permissions, not its mode. Root's code still runs in user mode and still asks the kernel; root is simply allowed to ask for more, including loading kernel modules, which is how root becomes kernel.
What interviewers probe next
- "Why must the kernel validate a user pointer even after checking that it points into user space?" Because the memory can be unmapped or changed by another thread between check and use, and because the check must happen with the right fault handling. Copy once, then validate the copy.
- "How does a hypervisor change this picture?" It adds a second privilege boundary below the guest kernel, so a guest kernel exploit needs a further hypervisor escape to reach the host or other guests.
- "What does seccomp actually reduce?" The set of kernel entry points reachable from the sandboxed process, and with it the kernel code an exploit can target. It does not change what allowed calls are permitted to do.
- "Is a system call expensive, and does that matter for security?" A mode switch costs real time, which is why some data is exposed through shared pages (the vDSO for time on Linux). Anything mapped that way is readable by every process, so it must contain nothing sensitive.
What if?
What if · interview follow-ups
Hold your answer as the constraints change
An interviewer asks why a bug in a web server process is less severe than a bug in the kernel on the same Linux machine.
Start here
What separates user space from the kernel?
Which mode can change page tables?
The CPU runs ordinary programs in an unprivileged mode that cannot touch hardware, page tables or other processes' memory. Only the kernel runs privileged, so it enforces every boundary on the machine.
Carry it forwardThe kernel enforces all other boundaries.
Weak answerThinking root runs in kernel mode.
Constraint changes
How does a program ask for privileged work?
Who chooses where execution continues?
Through a system call: a controlled entry point where the CPU switches mode and jumps to kernel code chosen by the kernel, which must validate every argument because it comes from untrusted user space.
Carry it forwardSystem calls are the controlled gate.
Weak answerAssuming arguments from user space are trusted.
Constraint changes
What does a web server bug give an attacker?
What limits the compromised process?
Code execution with that process's privileges: its user, files, network access and secrets. Bad, but bounded by permissions, sandboxing and the kernel's isolation.
Carry it forwardProcess bugs are bounded by kernel-enforced limits.
Weak answerTreating a process bug as harmless.
Constraint changes
What does a kernel bug give an attacker?
What remains to stop an attacker in the kernel?
Potentially control of the component enforcing every boundary: other processes, containers, users and security modules on the host. That is why kernel bugs often mean full host compromise.
Carry it forwardKernel bugs can break every boundary at once.
Weak answerAssuming containers protect against kernel bugs.
Constraint changes
How do you reduce kernel exposure?
Which kernel code can untrusted processes reach?
Patch kernels promptly, reduce reachable kernel surface with seccomp and disabled modules, keep untrusted workloads in gVisor or VMs, and enable kernel hardening features.
Carry it forwardPatch and shrink reachable kernel surface.
Weak answerIgnoring kernel advisories on container hosts.
Now defend it
How would you answer the interviewer?
The kernel runs privileged and enforces every boundary through validated system calls, so a web server bug is bounded by the process's permissions while a kernel bug can break all boundaries on the host; reduce risk with prompt patching, seccomp, fewer modules and stronger isolation for untrusted workloads.
How it's scored
Weak: "The kernel has more privileges than user programs." No mention of the system call path or of what the kernel must check.
Hire: Explains hardware-enforced modes, virtual memory, the system call instruction and the kernel's duty to validate arguments, and links kernel bugs to container escape.
Strong Hire: Adds pointer validation and double-fetch races, SMAP/SMEP, the distinction between root and kernel mode, and uses the boundary to justify seccomp, gVisor and VMs for untrusted code.
Common mistakes
- Saying root runs "in the kernel".
- Treating the boundary as a software convention rather than something the CPU enforces.
- Forgetting that arguments, especially pointers and lengths, are hostile input.
- Calling containers a kernel-level isolation boundary without noting the shared kernel.