Kernel lockdown is a Linux security module that restricts the root user from modifying the running kernel, and optionally from reading its memory, by disabling interfaces that would otherwise give userspace direct access to kernel code and data. In Linux security, it draws a boundary between root and the kernel itself, a boundary that traditional Unix permissions never had.
The feature was merged into the mainline kernel in Linux 5.4 after years of out-of-tree patches carried by distributions. Its main purpose is to preserve the UEFI Secure Boot chain of trust: if firmware verifies the bootloader and the bootloader verifies the kernel, a compromised root account should not be able to load arbitrary code into ring 0 afterward and silently defeat that verification.
How kernel lockdown separates root from the kernel
Kernel lockdown works by checking a lockdown reason at every sensitive entry point before the kernel allows the operation. Each restricted interface, such as module loading or raw memory access, calls a hook named security_locked_down() with a specific reason code, and the lockdown LSM compares that code with the current lockdown level.
The reason codes are ordered so that every integrity-related reason sits below a marker and every confidentiality-related reason sits above it. When the system runs in integrity mode, only the lower group is denied; in confidentiality mode, both groups are denied. A denied call returns an error, usually EPERM, and the kernel logs a message such as “Lockdown: modprobe: unsigned module loading is restricted”.
Lockdown is a one-way ratchet. An administrator can raise the level at runtime by writing to /sys/kernel/security/lockdown, but the kernel never allows the level to be lowered without a reboot. This property matters because an attacker with root access could otherwise simply switch the protection off.
Lockdown modes and what each one blocks
Kernel lockdown offers three levels, and the active one appears in brackets when the securityfs file is read. The following table summarizes the purpose and effect of each level.
| Mode | Goal | Typical effect on administration |
|---|---|---|
| none | No restrictions | Root keeps full access to kernel interfaces |
| integrity | Prevent modification of the running kernel | Unsigned modules, /dev/mem writes and unsigned kexec fail |
| confidentiality | Also prevent extraction of kernel secrets | Kernel memory reads via /proc/kcore, kprobes and some BPF helpers fail |
The list of blocked features is longer than most administrators expect. The next table groups the most relevant restrictions by the mode that first enforces them.
| Interface or feature | Blocked from mode | Reason for the restriction |
|---|---|---|
| Unsigned kernel modules | Integrity | Arbitrary ring 0 code execution |
/dev/mem, /dev/kmem, /dev/port | Integrity | Direct writes to physical memory and I/O ports |
| kexec of unsigned images | Integrity | Booting an unverified kernel without firmware checks |
| Hibernation to disk | Integrity | Resume image could be altered offline |
ioperm, iopl, MSR writes | Integrity | Hardware reprogramming that bypasses the kernel |
| ACPI table overrides | Integrity | Injected firmware code runs with kernel privileges |
/proc/kcore | Confidentiality | Exposes the whole kernel address space |
| kprobes, perf and tracefs access | Confidentiality | Can read kernel data and keys |
| BPF reads of kernel memory | Confidentiality | Can exfiltrate secrets such as disk encryption keys |
Integrity mode is the common default on distributions that enable lockdown automatically, because confidentiality mode also disables many tracing and observability tools that operations teams rely on.
Enabling and checking lockdown on a Linux system
Lockdown can be activated at build time, at boot or at runtime. The kernel must be compiled with CONFIG_SECURITY_LOCKDOWN_LSM, and the LSM must be included in the active LSM stack; CONFIG_SECURITY_LOCKDOWN_LSM_EARLY makes it start early enough to protect boot-time parameters.
| Method | Example | When it applies |
|---|---|---|
| Kernel configuration | CONFIG_LOCK_DOWN_KERNEL_FORCE_INTEGRITY | Always enforced for that kernel build |
| Boot parameter | lockdown=integrity | Every boot that uses the parameter |
| Secure Boot coupling | Distribution patch ties lockdown to UEFI state | Only when firmware reports Secure Boot enabled |
| Runtime securityfs | echo confidentiality > /sys/kernel/security/lockdown | Until reboot, raising only |
To check the current state, read /sys/kernel/security/lockdown; output such as none [integrity] confidentiality shows that integrity mode is active. The kernel log usually also records the trigger, for example a line stating that lockdown was enabled because Secure Boot is active. Fedora, Ubuntu, Debian and the Red Hat family all ship this coupling in some form, although the details differ between releases.
Kernel lockdown compared with other Linux security controls
Kernel lockdown complements, rather than replaces, the other controls in the Linux security toolbox. Mandatory access control systems such as SELinux and AppArmor restrict what processes may do to files, sockets and other objects, while lockdown protects the kernel as an object from the most privileged user.
| Control | What it protects | Who it constrains |
|---|---|---|
| Kernel lockdown | Kernel code and memory | Root and all userspace |
| SELinux and AppArmor | Files, processes and network objects | Confined domains or profiles |
| Linux capabilities | Individual privileged operations | Processes lacking a given capability |
| Seccomp | The system call surface | A filtered process and its children |
| Module signing | Kernel module authenticity | Anyone loading modules |
A frequent misconception is that removing CAP_SYS_MODULE or CAP_SYS_RAWIO achieves the same result. Capabilities can be regained by a fully privileged root process, whereas lockdown applies even to processes holding every capability, which is precisely the threat model Secure Boot requires.
Limitations and operational pitfalls
Lockdown raises the cost of a kernel compromise, but it does not make the kernel invulnerable. A memory corruption bug in the kernel itself still allows privilege escalation into ring 0, and lockdown cannot stop an attacker who already executes kernel code.
- Third-party drivers break when they are built locally through DKMS and are not signed; proprietary GPU drivers and some virtualization modules are the usual victims.
- Hibernation is disabled in integrity mode on mainline kernels, which surprises laptop users after enabling Secure Boot.
- Debugging becomes harder: confidentiality mode blocks crash analysis via
/proc/kcoreand many tracing tools. - Disabling Secure Boot through firmware or shim validation settings often removes lockdown as well, so the protection depends on firmware configuration staying intact.
The correct fix for unsigned modules is to enroll a Machine Owner Key and sign the modules, not to turn off Secure Boot. Teams should also treat lockdown as one layer of defense in depth, combined with prompt kernel patching and least-privilege administration.
Put simply
On a normal Linux system, the root user can do almost anything, including changing the core of the operating system while it runs. Kernel lockdown takes some of that power away. It is like a building where even the manager cannot open the main safe without the right key.
The point is simple: if a criminal steals the root password, they still cannot quietly rewrite the kernel. The price is that some tools and unsigned drivers stop working until they are properly signed.
In practice
A hosting provider runs several hundred Linux servers with UEFI Secure Boot enabled, and the distribution kernel therefore starts in integrity mode. During an incident, an attacker obtains root on one server through a vulnerable web application and tries to load a rootkit as a kernel module. The insmod call fails with a lockdown message, and the attempt appears in the system log within seconds.
The security team uses that log entry to detect the intrusion, rebuilds the server from a clean image and rotates credentials. Weeks earlier, the same lockdown had blocked an unsigned storage driver after an upgrade; the operations team solved that by signing the module with an enrolled Machine Owner Key. The outcome was a short maintenance task instead of a persistent, hidden kernel compromise.