Live patching

Also known as: kernel live patching

On this page 7

Live patching is the technique of modifying the code of a running kernel in memory so that a security or bug fix takes effect immediately, without rebooting the machine. In operating systems, and within the wider practice of OS updates & maintenance, it is used mainly to close critical kernel vulnerabilities on servers and workstations that cannot afford unplanned downtime.

The approach is also called kernel live patching. It does not replace regular kernel updates: it is a bridge that buys time between the disclosure of a flaw and the next planned maintenance window, when a full updated kernel is installed and the system restarts cleanly.

How live patching redirects kernel functions

A live patch works by replacing whole functions, not individual instructions. The patch is delivered as a loadable kernel module that contains corrected versions of the affected functions. When the module loads, the kernel places a redirection at the entry point of each original function so that every new call jumps to the fixed copy instead.

On Linux, the redirection relies on the ftrace function tracing framework, which already reserves a small patchable area at the start of most kernel functions. The livepatch subsystem registers a handler there that changes the instruction pointer to the new function. The old code stays in memory, which is why a later patch can be reverted by removing the redirection.

The hardest part is consistency. A thread may be sleeping inside a function that is being replaced, and switching it mid-execution could corrupt state. The Linux consistency model therefore moves each task to the patched state individually, only when its stack trace shows no patched function, or when it crosses the boundary between user space and kernel space. Until every task has transitioned, the patch is reported as being in transition.

The following table summarizes the stages that a typical kernel live patch passes through.

StageWhat happensTypical duration
BuildVendor compiles fixed functions into a patch moduleHours to days after disclosure
LoadModule is inserted and its signature is verifiedUnder one second
RedirectEntry points of old functions are redirectedMilliseconds
TransitionEach task switches once its stack is safeSeconds, sometimes minutes
CompleteAll tasks use the new codePersists until the next reboot
Stages of applying a kernel live patch

Live patching implementations by platform

Several mature implementations exist, and most enterprise Linux distributions ship their own service built on the upstream kernel livepatch interface, which was merged in Linux 4.0 in 2015. Earlier designs such as Ksplice, kGraft and kpatch shaped that interface. Windows has a different mechanism called hotpatching, available for selected Windows Server editions.

This table compares the main implementations and how they are typically consumed.

ImplementationPlatformDelivery model
Upstream livepatchLinux kernel 4.0 and laterInterface used by distribution tools
kpatchRed Hat Enterprise Linux and derivativesPatch modules from the vendor
kGraft lineageSUSE Linux EnterpriseSubscription live patching service
KspliceOracle LinuxVendor service, also covers some user space
Canonical LivepatchUbuntu LTS releasesClient agent with cloud-delivered patches
Windows hotpatchingSelected Windows Server editionsMonthly hotpatch updates between baseline releases
Common live patching implementations

Live patching compared with other update methods

Live patching is one tool among several for keeping a system current, and each method trades downtime against completeness. A conventional kernel update installs a new kernel image and requires a reboot to activate it. A/B system updates prepare a second system partition and switch to it on restart, which makes rollback simple but still needs a restart.

The comparison below places live patching next to its closest neighbors in OS updates & maintenance.

ApproachReboot neededScope of changeMain strength
Live patchingNoSelected kernel functionsZero downtime for urgent fixes
Kernel updateYesEntire kernel imageComplete and permanent fix
A/B system updatesYesWhole system partitionAtomic switch and easy rollback
In-place upgradeYes, often severalFull OS versionMoves to a new release
Service restartNoUser-space programs onlyReloads patched libraries quickly
Live patching versus related update approaches

A frequent misunderstanding is that live patching also updates user-space libraries such as the C library or OpenSSL. Most implementations cover only the kernel, so administrators still need to restart affected services after library updates.

When to use live patching in practice

Live patching is most valuable where reboots are expensive or risky: database hosts with long warm-up times, virtualization hosts carrying many guests, telecommunications nodes and industrial controllers. It fits naturally into patch management as the fast lane for critical kernel issues, while ordinary updates follow the normal schedule.

The decision table below shows typical situations and a sensible strategy for each.

SituationRecommended choiceReason
Actively exploited kernel flawApply a live patch nowCloses exposure before a window opens
Routine monthly kernel fixesSchedule a rebootFull kernel is simpler to support
Fix changes data structuresReboot with a new kernelSuch changes rarely suit live patches
Host running many virtual machinesLive patch, then migrate and reboot laterAvoids restarting all guests at once
Desktop or laptopNormal update and rebootDowntime cost is low
Choosing between a live patch and a reboot

Good practice is to verify the patch state after loading, for example by checking the enabled patches and the transition status that the kernel reports through /sys/kernel/livepatch. Monitoring should alert when a patch remains stuck in transition.

Limitations and risks of live patching

Live patching has real technical limits, and vendors decide case by case whether a fix can be delivered this way. Patches that change data structure layouts, alter initialization code that has already run, or modify assembly entry paths are hard or impossible to apply live. In those cases the vendor publishes only a regular kernel update.

  • Patches accumulate: each live patch is usually cumulative, and vendors support a given kernel build only for a limited period, often about one year, after which a reboot to a newer kernel is required.
  • Not persistent across reboots by itself: the patch module must be loaded again at boot, which the vendor agent normally handles.
  • Security of the mechanism: loading code into a running kernel is powerful, so patch modules must be cryptographically signed, especially when Secure Boot is enabled.
  • False sense of completeness: a system that reports itself as patched may still run vulnerable libraries or firmware.

For these reasons, experienced administrators treat live patching as risk reduction, not a substitute for rebooting. A planned restart onto a fully updated kernel remains part of a healthy maintenance cycle.

A plain-language summary

The kernel is the core of an operating system, and fixing it normally means restarting the computer. Live patching swaps out the broken parts while the machine keeps running, a little like replacing a faulty light switch in a building without turning off power to every floor.

It is mainly used for urgent security fixes on servers that must stay online. It is not permanent on its own, so the computer is still restarted later, at a convenient time, onto a fully updated system.

An example from practice

A regional hospital runs its patient records database on a cluster of Linux servers that must remain available around the clock. When a privilege escalation flaw in the kernel networking code is disclosed and reported as actively exploited, the infrastructure team cannot wait for the quarterly maintenance window, which is six weeks away.

The distribution vendor releases a live patch two days later. The team tests it on a staging server, confirms that the transition completes in under a minute, and then rolls it out to all twelve production nodes through their configuration management tool. No service interruption occurs, and monitoring confirms that every node reports the patch as enabled.

At the next maintenance window, the servers are rebooted onto a new kernel that includes the fix permanently. The outcome is that the exposure window shrank from six weeks to about three days without any planned downtime.