Architecture Note: Implementing Ubuntu Canonical Livepatch for Zero-Downtime Kernel Security
Learn the architecture of Ubuntu Canonical Livepatch, including ftrace-based function redirection, trust boundaries, and operational verification for zero-downtime kernel patching.
13 Dec 2025, 10:25 UTC

The Problem: The Reboot Cycle Gap
Critical kernel vulnerabilities (CVEs) often require a full system reboot to apply fixes. In high-availability production environments, scheduling maintenance windows for reboots creates a "security gap"—the time between a patch release and the next scheduled restart. This gap leaves systems exposed to known exploits.
The takeaway: Canonical Livepatch allows the application of critical security fixes to the running kernel without rebooting, using ftrace-based function redirection to swap vulnerable code for patched code in memory.
Requirements for Livepatching
- OS Version: Ubuntu LTS (Long Term Support) releases (e.g., 20.04, 22.04, 24.04).
- Kernel Compatibility: The running kernel must match the ABI (Application Binary Interface) of the delivered payload.
- Infrastructure:
snapdmust be installed and functional, as it serves as the delivery mechanism. - Authorization: A valid Ubuntu Pro token (free for up to 3 machines) for identity and payload access.
Minimal Design and Mechanism
The smallest suitable design for livepatching avoids replacing the entire kernel. Instead, it uses a cumulative payload approach.
The system delivers a signed kernel module (livepatch-payload-*) via a snap. This module contains only the minimal set of function replacements needed to fix specific CVEs. The core mechanism relies on ftrace: when the kernel calls a vulnerable function, ftrace redirects the execution flow to the patched version provided by the livepatch module.
The transition occurs via klp_enable_patch(). The kernel uses a consistency model (ACTIVE_UNLOADING) to ensure that no process is currently executing the code being replaced before the switch is finalized, preventing system crashes.
Trust and Data Boundaries
To prevent the execution of malicious code in kernel space, Livepatch employs a strict trust chain:
- Payload Signing: All payloads are signed by Canonical's private key.
- Verification: The kernel enforces
CONFIG_MODULE_SIG, verifying the payload against theubuntu-livepatch-keyringembedded in the system. - Delivery Path:
snapdmediates the download and installation, ensuring the package originates from the official Canonical channel. - Identity: Access is restricted via a machine-id and token, ensuring only authorized systems receive specific kernel payloads.
Operational Verification
Verification must be performed at both the user-space tool level and the kernel interface level.
User-Space Check
Run the following command as a user with sudo privileges to check the current status:
sudo canonical-livepatch status --verbose
Expected Result: The state should be applied. If it shows pending, the patch is downloaded but not yet active in the kernel.
Kernel-Space Check
To verify the patch is actually active in the kernel's runtime memory, inspect the sysfs interface:
cat /sys/kernel/livepatch/<patch_id>/enabled
Expected Result: A value of 1 indicates the patch is enabled. A value of 0 indicates it is loaded but inactive.
Log Diagnostics
Check the kernel ring buffer for klp (Kernel Live Patching) messages:
dmesg -T | grep -i livepatch
Failure Modes and Constraints
| Failure Mode | Cause | Symptom |
|---|---|---|
| Consistency Failure | Target function is in use and cannot transition safely. | Patch remains pending; -EAGAIN in logs. |
| ABI Mismatch | Kernel was upgraded via apt but Livepatch hasn't refreshed. |
Payload fails to load; version mismatch error. |
| Signature Denial | Corrupted snap or outdated ubuntu-livepatch-keyring. |
dmesg shows module signature verification failed. |
| Confinement Block | AppArmor profile prevents snapd from writing to kernel paths. |
Permission denied errors in journalctl -u snap.canonical-livepatch. |
Design Change Triggers
The current architecture is stable for LTS releases, but the following conditions would necessitate a design shift:
- Major ABI Breaks: A significant kernel version jump that changes the function signatures would require a complete new payload series.
- FIPS 140-3 Compliance: Strict FIPS modes may restrict the dynamic loading of modules, requiring a shift toward pre-compiled secure boot images.
- Key Rotation: A compromise or expiration of the Canonical signing key would require a fleet-wide update of the
ubuntu-livepatch-keyringpackage before new patches could be applied.
Limitations
Livepatch is not a replacement for regular updates. It only addresses critical kernel-space CVEs. User-space libraries (such as glibc or openssl) cannot be live-patched in this manner and still require a service restart or system reboot to apply updates.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.