Kernel Live Patching with kpatch: Applying Security Updates Without a Reboot
AI generated
$
/etc
Linux
Kernel Live Patching
Applying security updates without a reboot

A critical kernel CVE traditionally forces a reboot with a downtime window, even when the affected server is really just a single, highly available member of a database cluster. Kernel live patching through kpatch or commercial offerings like Canonical Livepatch closes exactly that gap, but it never replaces the regular reboot cycle needed for larger kernel upgrades.

9 min read Linux Kernel Security

1. Why patch without a reboot at all?

A kernel security update traditionally only takes effect after a reboot, since the running kernel in memory stays unchanged until the system restarts and loads the updated kernel. For a single web server behind a load balancer, that is usually not a big deal, but for a heavily loaded database primary, a stateful cache cluster node, or a server running very long cron jobs, a reboot costs real time and creates real coordination overhead.

Kernel live patching addresses exactly this: a critical security fix gets applied to the already running kernel at runtime, without losing process memory or dropping active network connections. The actual reboot that brings new features, larger structural changes, or a new major kernel version is still due on a regular basis, and live patching only makes it schedulable rather than replacing it entirely.

2. How kpatch works technically

kpatch builds on the same ftrace mechanism also used for kernel tracing: at the entry point of a patched function, a jump instruction gets inserted that redirects the call to the new, corrected function version, while the original function code stays unchanged in memory. This technique is called function redirection and works because the kernel already carries a mechanism for ftrace instrumentation on nearly every function.

The actual patch is not written by hand, but generated by kpatch-build from two versions of the kernel source code: the original and the patched variant. The tool compiles both versions, compares the resulting object files, and automatically extracts only the functions that actually changed into a loadable kernel module.


# Build a kpatch kernel module from a source patch (simplified example)
kpatch-build -t vmlinux \
  --sourcedir /usr/src/kernels/$(uname -r) \
  cve-2026-xxxxx.patch

# Result: a loadable kernel module
ls kpatch-*.ko

3. The kpatch toolchain in day to day use

In day to day operation, the routine work usually boils down to three commands: kpatch load loads an already built patch module into the running kernel, kpatch list shows every currently active patch along with the functions it touches, and kpatch unload removes a patch again, provided no other dependency blocks it.

For persistence across a reboot, the systemd service kpatch.service automatically reloads every patch stored under /var/lib/kpatch at system startup. Without this step, every live patch would disappear after a regular reboot, since a freshly started kernel naturally starts out in its unpatched state again.


# Load a patch module and register it permanently for future boots
sudo kpatch install kpatch-cve-2026-xxxxx.ko
sudo kpatch load /var/lib/kpatch/$(uname -r)/kpatch-cve-2026-xxxxx.ko

# List active patches and the functions they affect
sudo kpatch list

# Remove a patch again if needed
sudo kpatch unload kpatch-cve-2026-xxxxx

4. Canonical Livepatch for Ubuntu servers

Canonical offers Ubuntu LTS servers its own cloud backed service called Livepatch, which automatically fetches prebuilt patches through an Ubuntu Advantage or Ubuntu Pro subscription and applies them in the background, without administrators having to build a patch themselves with kpatch-build. The service remains usable for a limited number of machines even without a paid subscription.

Activation happens through the canonical-livepatch command line tool, which needs a one time activation token from an Ubuntu One account and then autonomously downloads new patches as soon as Canonical releases them for the installed kernel version.


# Install the Livepatch client and enable it with a token
sudo snap install canonical-livepatch
sudo canonical-livepatch enable <TOKEN>

# Show status and the patches currently applied
sudo canonical-livepatch status --verbose

5. Red Hat kpatch and SUSE kGraft compared

Red Hat integrates kpatch directly into RHEL and offers prebuilt patches for selected, security relevant CVEs through the Red Hat Kernel Livepatch Service, installable through the regular package manager as a kpatch-patch package once a Red Hat subscription with the right entitlement is in place. The service deliberately covers only a subset of all CVEs, prioritized by actual exploitation risk.

SUSE takes a technically related but independently implemented approach with kGraft, which also relies on function redirection but uses its own consistency model to cleanly synchronize the transition between the old and new function while calls to the affected function are still in flight.


# RHEL: list available kpatch patches for the running kernel
sudo yum list available 'kpatch-patch*'

# Install a specific patch package
sudo yum install kpatch-patch-5_14_0-570

# Check the active patch status
sudo kpatch list

6. Limits: not every CVE can be live patched

Live patching works reliably for locally scoped function fixes, such as a faulty bounds check in a network driver. But once a security fix reaches deep into data structures, for example requiring a new structure size or changed locking behavior that would collide with already running instances still in the old format, the patch cannot be safely implemented as a pure function redirect.

In such cases, kpatch-build marks the build as failed, or the patch vendor simply does not ship a live patch for that CVE at all and points explicitly to a regular kernel reboot instead. Live patching is therefore a complement to regular patch management, not a full replacement, and a reboot window should never disappear entirely from the schedule just because a live patching program is in place.

7. Monitoring and verifying active patches

In a mixed server landscape with many machines, it is worth centrally tracking which live patch level is active on which host, since kpatch list only reports locally. A simple monitoring script that reads the status regularly and reports it to a central monitoring system prevents individual servers from silently falling behind the expected patch level.

Beyond a simple status check, it is worth cross referencing the running kernel version from uname against the list of known, still open CVEs, since kpatch list shows which patches are loaded, but does not automatically confirm that every relevant security issue for that kernel version has actually been closed.


# Simple check for monitoring systems: number of active patches
kpatch list | grep -c '\[enabled\]'

# Capture kernel version and patch level together
echo "kernel=$(uname -r) patches=$(kpatch list | grep -c enabled)"

8. Integration into the regular patch management process

Live patching should be understood as an additional, faster response layer for critical CVEs, not a replacement for the regular maintenance cycle. A sensible process reacts to a freshly published critical CVE with a live patch first, if one is available, and still schedules the full kernel reboot with the regular update for the next planned maintenance window.

Documenting which live patches are active on which server also matters, because a later regular reboot with the full kernel update makes the live patch obsolete and automatically supersedes it. Without clean tracking, uncertainty creeps in about whether a server actually ends up at the same security level after a reboot that it previously reached through live patching alone.

9. Practical example: use in a Magento hosting context

On a MySQL primary serving a Magento cluster with several frontend nodes, or a Redis node holding session and cache data for many concurrent checkout flows, an unplanned reboot outside a maintenance window is especially costly, since failover mechanisms can cause brief interruptions even with a clean design. Live patching allows reacting to a critical kernel CVE within minutes without taking on that risk.

For stateless web servers behind a load balancer, the extra effort for live patching pays off less often, since a rolling reboot of individual nodes is usually possible without noticeable downtime anyway. The biggest payoff from live patching therefore sits specifically with the few, genuinely critical servers in the infrastructure that are hard to make redundant.

Provider Target system Cost Coverage
kpatch, self built RHEL, Fedora, generic compiling possible Free, but requires effort for kpatch-build Only self built patches, full control
Red Hat Kernel Livepatch Service RHEL with a valid subscription Included in a Red Hat subscription Selected critical CVEs, prioritized by risk
Canonical Livepatch Ubuntu LTS servers Free for a limited scope, otherwise Ubuntu Pro Broad coverage for supported LTS kernels
SUSE kGraft SUSE Linux Enterprise Server Included in a SUSE subscription Comparable to Red Hat's offering, own model

Mironsoft

Server administration, Docker hosts, and performance tuning

Linux servers nobody on the team really understands anymore?

We handle setup, hardening, and performance tuning of Linux servers and Docker hosts for Magento deployments, documented and traceable instead of grown and unclear.

Server Audit

Review the existing server configuration for security gaps and performance bottlenecks.

Docker Host Setup

Set up and secure production-ready Docker environments for Magento cleanly.

Monitoring & Tuning

Measure resource usage and tune systemd, kernel, and services with purpose.

10. Summary

Kernel Live Patching

Technique

ftrace based function redirection, delivered as loadable kernel modules

Best fit

Critical servers hard to make redundant, like database primaries

Key limitation

Not every CVE can be patched without a structural data change

Does not replace reboots

Regular reboot windows for kernel upgrades remain necessary

11. FAQ: Kernel Live Patching

1What is the difference between kpatch and Livepatch?
kpatch is the underlying technique and toolchain built into the Linux kernel itself, while Livepatch is a commercial service from Canonical that automatically fetches and applies prebuilt patches, without administrators having to build their own patches with kpatch-build.
2How does kernel live patching work technically?
Through ftrace based function redirection, a jump to the corrected version gets inserted at the entry point of an affected function, while the original code stays in memory. The patch itself is delivered as a loadable kernel module into the running kernel.
3Does live patching replace the regular kernel reboot entirely?
No, larger structural changes, new major kernel versions, and deep reaching security fixes still require a classic reboot. Live patching only closes the gap until the next scheduled maintenance window for critical, locally scoped fixes.
4Which CVEs cannot be closed with a live patch?
Fixes that require a changed data structure size or different locking behavior collide with already running instances still in the old format and cannot be safely implemented as a pure function redirect. In such cases, only a regular reboot remains an option.
5What happens to a live patch after a normal reboot?
A live patch only exists in the memory of the running kernel. After a regular reboot with an updated kernel package, the live patch's fix is already included in the new kernel version and automatically becomes obsolete.
6How do I check which live patches are currently active?
The command kpatch list shows every loaded patch and the functions it affects, locally on that server. For a larger server landscape, centrally collecting this status regularly through monitoring is worth setting up as well.
7Does Canonical Livepatch cost anything?
The service remains free for a limited number of machines, while larger environments need an Ubuntu Pro or Ubuntu Advantage subscription, which unlocks the full feature set and coverage for more machines.
8Is live patching worthwhile for every server?
It pays off the most for critical servers that are hard to make redundant, such as database primaries or stateful cache nodes. For stateless web servers behind a load balancer, a simple rolling reboot is usually enough without the extra effort of live patching.
9How do I build my own kpatch patch for RHEL or Fedora?
With the kpatch-build tool, which automatically extracts only the changed functions from the original kernel source code and a patched variant, packaging them as a loadable kernel module. The tool needs a full kernel build environment to do this.
10Does a live patch stay active automatically after a reboot?
Yes, provided the patch was previously registered permanently with kpatch install. The systemd service kpatch.service automatically reloads every patch stored under /var/lib/kpatch at system startup, as long as that kernel has not already been superseded by a regular update.