Hardware-Assisted Live Kernel Function Updating on Intel Platforms

Lei Zhou, Fengwei Zhang, Kevin Leach, Xuhua Ding, Zhenyu Ning, Guojun Wang, Jidong Xiao

TL;DR

KSHOT is a hardware-assisted framework that enables live-patching of operating system kernels without requiring a reboot or trusting the underlying OS. By combining Intel SGX for secure patch preparation and System Management Mode (SMM) for high-privilege execution, it achieves critical security updates with just 70 microseconds of downtime and a tiny 18 MB memory footprint.

What Problem Does This Paper Address?

Updating an OS kernel usually requires a system reboot, leading to costly downtime for cloud providers and enterprises. While "live patching" tools like kpatch or Ksplice exist, they suffer from a fundamental "Catch-22": they rely on the very kernel they are trying to fix.

If a kernel is already compromised by a rootkit or a severe vulnerability, the built-in patching mechanism cannot be trusted. An attacker could hijack the update process to install malicious code instead of a fix. Furthermore, existing software-only solutions often incur significant performance overhead or require complex "checkpointing" (saving the state of every running app), which can take seconds—an eternity in high-speed computing environments.

Methods

KSHOT introduces a two-stage, hardware-isolated pipeline to solve the trust and downtime issues:

  1. Secure Preparation (Intel SGX): KSHOT uses an Intel SGX enclave—a hardware-protected "black box" in memory—to download and verify patch source code from a remote server. Because the enclave is isolated from the OS, even a compromised kernel cannot see or tamper with the patch before it’s ready. The enclave performs binary "diffing" and prepares the new function instructions.
  2. Live Updating (x86 SMM): Once the patch is ready, KSHOT triggers a System Management Interrupt (SMI), which forces the CPU into System Management Mode (SMM). SMM is a highly privileged "god mode" that operates underneath the OS. While in SMM, the entire OS is paused. A custom SMM handler then writes the patch directly into kernel memory using trampolines (replacing the first instruction of an old function with a jmp to the new code).
  3. Consistency Management: To ensure the system doesn't crash, KSHOT identifies three types of patches: simple function replacements (Type 1), patches involving inlined code (Type 2), and complex changes to global data structures (Type 3).

Datasets

The authors evaluated KSHOT using a suite of real-world vulnerabilities:

  • CVE Database: They analyzed 267 vulnerabilities from the Common Vulnerabilities and Exposures (CVE) database for Linux kernels 3.14 and 4.4.
  • Benchmark Suite: They randomly selected 30 representative patches from the 214 applicable vulnerabilities to test KSHOT’s correctness and performance.
  • Kernel Modules: They also tested the system's ability to update dynamic drivers, such as the NVIDIA GPU driver and various filesystem/network modules.

Key Insights and Ideas

  • Bypassing the OS: The core "aha" moment is using SMM to perform the update. Since SMM can see all physical memory and pauses all CPU cores simultaneously, it provides a perfectly consistent "snapshot" of the system to apply patches without the OS ever knowing it happened.
  • Parallel Patching: Because each CPU core has its own SMM handler, KSHOT can sort multiple update tasks and execute them in parallel across cores, significantly reducing the time the system stays paused.
  • Reduced TCB: By moving the update logic into SGX and SMM, the Trusted Computing Base (TCB)—the set of hardware and software you must trust for security—is drastically reduced. You no longer need to trust the millions of lines of code in the Linux kernel; you only trust the hardware and the small KSHOT handler.

Key Results

  • Minimal Downtime: For a standard 1 KB binary update, KSHOT incurs only 70 microseconds of downtime. For comparison, the KUP system takes about 3 seconds, and kpatch takes roughly 45 milliseconds.
  • Low Overhead: The system requires only 18 MB of reserved memory for its operations, whereas some previous approaches (like KUP) required over 30 GB to support application checkpointing.
  • Security: KSHOT successfully mitigated "Malicious Update Reversion" attacks, where a rootkit tries to undo a security patch, by using SMM-based introspection to verify that the patch remains in place.

Limitations and Future Work

The authors acknowledge that KSHOT currently struggles with Type 3 patches—those that involve significant changes to the layout of kernel data structures (e.g., adding a new field to a widely used struct). Changing these layouts at runtime without crashing the system remains a difficult open challenge in the field of dynamic software updating.

Additionally, KSHOT is currently tied to Intel-specific hardware features (SGX and SMM). Future work could involve porting these concepts to other architectures, such as using ARM TrustZone or AMD’s Secure Encrypted Virtualization (SEV).

Summary updated

Abstract

Traditional kernel updates such as perfective maintenance and vulnerability patching requires shutting the system down, disrupting continuous execution of applications. Enterprises and researchers have proposed various live updating techniques to patch the kernel with lower downtime to reduce the loss of useful uptime. However, existing kernel live update techniques either rely on specific support from the target OS, or are deployed in virtualized environments (i.e., systems running in virtual machines). In this paper we present <sc xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">KShot</small> , a hardware-assisted live and secure kernel function update mechanism for native operating systems. By leveraging x86 SMM and Intel SGX, <sc xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">KShot</small> runs in hardware-assisted Trusted Execution Environments and updates kernel functions at the binary-level without relying on the underlying OS support. We demonstrate the applicability of <sc xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">KShot</small> by successfully patching critical kernel vulnerabilities, upgrading base kernel functions and drivers nearly instantly and transparently. Our experimental results show that <sc xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">KShot</small> incurs merely 70 microseconds downtime to update a one kilobyte binary and 18 MB memory overhead.
BibTeX
@article{zhou2023hardware,
  author = {Lei Zhou and Fengwei Zhang and Kevin Leach and Xuhua Ding and Zhenyu Ning and Guojun Wang and Jidong Xiao},
  title = {{Hardware-Assisted Live Kernel Function Updating on Intel Platforms}},
  journal = {IEEE Transactions on Dependable and Secure Computing},
  year = {2023},
  doi = {10.1109/tdsc.2023.3300101},
}
Figure