Concurrent Module Patching via Thread-Local Storage Allocation
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for concurrently patching computer programs do not allow for the loading of modules after initial loading, fail to handle function pointers transparently, and cannot change the size of existing variables, limiting their applicability and flexibility.
Innovation Solution
The proposed solution involves a method for concurrently loading new modules by preparing a memory layout with thread-local storage (TLS) blocks and dynamic memory allocation, allowing for the replacement of original modules, resolving dependencies, and safely removing function pointers, while also enabling the change in size of existing variables through relocation and adaptation of code.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If conventional concurrent patching methods are used, then the currently running code can be replaced with new code, but modules cannot be loaded after initial loading and function pointers cannot be handled transparently
Solution Approach 1:
The system segments the patching functionality into distinct components: a concurrent loader process for loading modules, a relocation mechanism for adapting addresses, and a function pointer management system. This segmentation allows each component to handle specific aspects of module loading independently, enabling post-initialization module loading without overwhelming system complexity.
Solution Approach 2:
The patent introduces an intermediary relocation mechanism that sits between the loaded modules and the executing code. This intermediary handles address translations and function pointer updates automatically, allowing modules to be loaded and linked without requiring the executing program to understand or manage the complexity of concurrent patching operations.
2Reliability
If static data variables are preserved during concurrent patch application, then variable content is maintained, but function pointers may point to incorrect addresses after patching
Solution Approach 1:
The system implements a feedback mechanism where the concurrent loader monitors static data variables containing function pointers during and after patch application. When a patch is applied, the loader detects changes in code addresses and automatically updates function pointers in static data variables to maintain their validity, ensuring both data preservation and pointer correctness.
Solution Approach 2:
The patent applies preliminary action by pre-identifying all static data variables that contain function pointers before patch application. The concurrent loader prepares a list of variables requiring update and schedules their modification in advance, ensuring that function pointers are corrected before they are used, thus preventing invalid address access while preserving other static data.
3Productivity
If a concurrent loader process is used to replace complete computer program code, then patching can be done atomically, but the process is transparent only to programmers who need to know about function pointers
Solution Approach 1:
The concurrent loader is designed to be self-service by automatically detecting and handling function pointers in static data variables without requiring programmer intervention. The loader scans for function pointers, tracks their locations, and performs updates autonomously during the patching process, making the system easier to operate while maintaining high patching efficiency.
4Ease of manufacture
If standard linker programs are used for generating code load, then the concurrent patch application is transparent to programmers, but function pointers cannot be handled transparently
Solution Approach 1:
The patent makes the concurrent loader universal by designing it to handle both standard code loading and function pointer management through a single integrated process. The loader can process standard ELF format code loads using conventional linkers while simultaneously identifying and managing function pointers, thus maintaining ease of code generation while adding function pointer adaptability.
Data Source
AI summary
Techniques are disclosed for concurrently loading a plurality of new modules while code of a plurality of modules of an original computer program is loaded and executed on a computer system. An associated method may include allocating a module thread local storage (TLS) block for each thread within an initial computer program, wherein the allocated module TLS blocks are large enough to hold all module thread variables that are loaded or to be loaded. The method further may include reserving spare areas between the module TLS blocks for adding new module thread variables and arranging at an end of the module TLS blocks a thread data template section for resetting threads or creating new threads. The method may result in addition of modules to the original computer program and/or application of a concurrent patch through replacement of one or more of the plurality of original computer program modules.


