OS Kernel Runtime Patching via Thread Flags and Trampolines

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing operating systems (OS) require rebooting or halting of processors to patch kernel functions, which is costly and disruptive, especially in multi-processor servers and standalone devices, making them unavailable during the patching process.

Innovation Solution

A method for runtime patching of an OS that involves loading a patch function within the kernel, setting and unsetting flags for each kernel thread, and using trampoline functions to gradually migrate threads to the updated patch function without stopping the OS, ensuring consistency and atomic execution.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If a reboot is performed to patch the OS kernel, then consistency between processes is ensured, but system availability is lost and downtime increases

Engineering Contradiction:
Improveconsistency between processesVSAvoiddowntime
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent implements dynamic function replacement in the OS kernel by introducing a flag mechanism that allows the kernel to switch between an existing function and a patch function at runtime. The flag is set when a patch is loaded and checked by trampoline functions, enabling dynamic redirection of kernel threads to patched code without system restart. This dynamic approach maintains process consistency while avoiding full system shutdown.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent performs preliminary actions by loading the patch function and setting the flag before actually applying the patch to running processes. The trampoline functions are prepared in advance to handle both patched and unpatched code paths. This preliminary setup ensures that when the patch is applied, the transition is smooth and consistent without requiring system reboot.

Inventive Principle:
Principle #10Preliminary action

2Reliability

If all processors are stopped to apply a patch, then consistency is maintained, but productivity and system availability decrease

Engineering Contradiction:
Improveconsistency during patchingVSAvoidsystem availability
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent segments the patching process into individual thread-level operations rather than system-wide shutdown. Each kernel thread is independently tracked using per-thread flags, allowing the patch to be applied thread-by-thread while other threads continue execution. This segmentation enables partial system operation during patching, maintaining productivity while ensuring consistency for patched threads.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent introduces trampoline functions as intermediaries between the patched code and the original kernel functions. These trampoline functions check the flag status and redirect execution appropriately, serving as a mediator that allows smooth transition without stopping other processors. This intermediary mechanism ensures consistency for patched threads while leaving other system operations unaffected.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Reliability

If the OS is halted for patching, then safety and consistency are ensured, but ease of operation and user access are reduced

Engineering Contradiction:
Improvesafety during patchingVSAvoiduser access during update
Core Design Contradiction:
ReliabilityVSEase of operation

Solution Approach 1:

The patent implements periodic checking of the patch flag by trampoline functions inserted throughout the kernel code path. Instead of a single system halt, the patch application occurs periodically at function entry/exit points where the flag is checked. This periodic mechanism allows users to continue accessing the system while patched functions are gradually applied, maintaining ease of operation while ensuring safety through consistent flag verification.

Inventive Principle:
Principle #19Periodic action

Data Source

PatentUS9652221B2Runtime patching of an operating system (OS) without stopping execution
Publication Date: 2017.05.16 SUSE LLC
  • US9652221B2 patent drawing
  • US9652221B2 patent drawing
  • US9652221B2 patent drawing

AI summary

Techniques for runtime patching of an OS without stopping execution of the OS are presented. When a patch function is needed, it is loaded into the OS code. Threads of the OS that are in kernel mode have a flag set and a jump is inserted at a location of an old function. When the old function is accessed, the jump uses a trampoline to check the flag, if the flag is set, processing returns to the old function; otherwise processing jumps to a given location of the patch. Flags are unset when exiting or entering the kernel mode.