Kernel Online Patching via Breakpoint Exception Handling
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing kernel hot patching technologies interrupt the operation of other threads in the system, failing to meet the high reliability requirements of carrier-class products as they require system restarts and interrupt normal operation.
Innovation Solution
A method for kernel online patching that loads a pre-generated patch file, sets a breakpoint at the execution start position of a primitive function, modifies the returning execution address to the patch function, and removes the breakpoint when a breakpoint exception occurs, allowing kernel patching without system restarts.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If kernel hot patching technology is used to renovate kernel function during operation, then system reliability is improved by avoiding system restart, but normal operation of other threads is interrupted
Solution Approach 1:
The patent segments the kernel patching process into multiple independent stages: patch validation stage (where threads are stopped to verify patch correctness) and patch recovery stage (where threads are resumed to continue normal operation). This segmentation allows the system to achieve reliable patching while minimizing interruption to normal thread operations.
Solution Approach 2:
The patent implements preliminary action by first validating the patch file before actually applying it to the kernel. The system stops threads, validates the patch integrity and correctness, and only after successful validation does it proceed to recover and apply the patch. This preliminary validation prevents incorrect patches from disrupting normal operation.
2Manufacturing precision
If stop_machine_run system function is employed to create non-interrupted thread with highest priority for patch validation, then patch validation can be performed, but operation of all other threads is interrupted
Solution Approach 1:
The patent implements periodic action by using a wait queue mechanism where threads are periodically stopped and resumed in a controlled manner. The system can pause thread execution during validation, then resume them after patch application, allowing patch validation to be performed accurately while maintaining overall thread operation continuity through periodic rather than continuous interruption.
Data Source
AI summary
A method, a device, and a system for realizing kernel online patching are provided. The method includes loading a pre-generated patch file in an operating system, setting a first breakpoint at an execution start position of the primitive function when a system thread executes the primitive function and a breakpoint exception occurs during the thread execution process due to the first breakpoint, modifying a returning execution address of the first breakpoint into the destination address of the patch function corresponding to the primitive function according to the first corresponding relation, and removing the first breakpoint. The kernel online patching implementation has a small impact on the normal operation of the operating system. The patch function becomes valid without restarting the operating system, thereby satisfying the high reliability requirements of carrier-class products.


