WO2011097901A1 - 在线补丁的激活方法、装置及系统 - Google Patents

在线补丁的激活方法、装置及系统 Download PDF

Info

Publication number
WO2011097901A1
WO2011097901A1 PCT/CN2010/078271 CN2010078271W WO2011097901A1 WO 2011097901 A1 WO2011097901 A1 WO 2011097901A1 CN 2010078271 W CN2010078271 W CN 2010078271W WO 2011097901 A1 WO2011097901 A1 WO 2011097901A1
Authority
WO
WIPO (PCT)
Prior art keywords
function
instruction
patch
patched
storage space
Prior art date
Application number
PCT/CN2010/078271
Other languages
English (en)
French (fr)
Inventor
余加强
郑伟
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP10845571.8A priority Critical patent/EP2434394B1/en
Publication of WO2011097901A1 publication Critical patent/WO2011097901A1/zh
Priority to US13/336,227 priority patent/US9075692B2/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/656Updates while running

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to an online patch activation method, apparatus, and system.
  • An online patch refers to a patch that is valid without restarting a program during program running, and is widely applied to various types of software.
  • the basic principle of activating an online patch is to replace the instruction at the entry of the original function (that is, the function to be patched) with the jump instruction, and then jump to the program that called the original function by replacing the jump instruction. Executed in the patch function.
  • the unconditional jump instruction occupies 5 bytes.
  • the online patch When the online patch is activated, most of the cases will overwrite the 3 instructions at the entrance of the original function, which is called the 3 instructions in the original function.
  • the 5-byte area is the critical section. If the instruction at the entry of the original function is directly replaced with the jump instruction when the online patch is activated, when there are multiple threads in the process, it is possible that a certain thread executes to the critical section (for example, execution to the first or second section) At the time of the instruction), the thread switching occurs. If the online patch is activated at this time, the program will be abnormal after the thread is switched back because the critical section code of the original function has been overwritten by the new jump instruction.
  • the prior art generally uses the Pannus patch technology, and specifically includes the following steps:
  • Pannus Since Pannus first suspends the original function process and then checks whether the EIP values of all threads are in the critical section, program exceptions due to direct writes can be avoided to some extent.
  • Embodiments of the present invention provide a method and system for activating an online patch of software to improve security and reliability of an online patch activation of an application software.
  • An online patch activation method includes the following steps:
  • a long jump instruction for jumping to the patch function in the intermediate area where the intermediate area is at the entrance of the function to be patched Before or after the location, and can store at least one storage space of long jump instructions;
  • the communication system includes at least one CPU and an internal memory, an operating system is running on the CPU, and at least one application program is run on the operating system, and the application program is associated with a patch management thread. And at least one business thread, where:
  • the memory is loaded with an application including at least one function to be patched and a patch file including a patch function, wherein the storage location of the to-be-patched function has a storage capable of placing at least one long jump instruction before or after the entry position Space
  • the patch management thread is configured to locate an address of the patch function and an entry address of the to-be-picked function during operation of the application, and write in the storage space for jumping to the a long jump instruction of the patch function, and modifying an instruction at the entry position of the to-be-picked function to a short jump instruction for jumping to the storage space;
  • the service thread is configured to execute a short jump instruction to the entry position of the to-be-patched function, jump to the storage space, and jump to the patch function execution by execution of the instruction in the storage space.
  • a patch management device comprising:
  • An address locating unit configured to locate an address of a patch function associated with the application and an entry address of the function to be patched during the running of the application to be patched;
  • a long jump instruction unit configured to write, in the intermediate area, a long jump instruction for jumping to the patch function based on an address of the patch function and an entry address of the to-be-picked function, where the middle The area is the storage space before or after the entry point of the function to be patched, and at least one long jump instruction can be placed;
  • a short jump instruction unit configured to modify an instruction at an entry position of the function to be patched to jump to a short jump instruction of the intermediate area, so that after the short jump instruction is executed, jump to the middle The area is jumped to the patch function execution by execution of the instruction in the intermediate area.
  • the communication system includes at least one processor core and a memory, the processor core runs an operating system, and at least one application program runs on the operating system, and the application program is associated with There are patch management threads and at least one business thread, where:
  • the memory is loaded with an application including at least one function to be patched and a patch file including a patch function, wherein the storage location of the to-be-patched function has a storage capable of placing at least one long jump instruction before or after the entry position Space
  • the patch management thread is configured to locate an address of the patch function and an entry address of the to-be-picked function during operation of the application, and write in the storage space for jumping to the a long jump instruction of the patch function, and modifying an instruction at the entry position of the to-be-picked function to a short jump instruction for jumping to the storage space;
  • the service thread is configured to execute a short jump instruction to the entry position of the to-be-patched function, jump to the storage space, and jump to execution by the execution of the instruction in the storage space to the patch function. It can be seen that, in the embodiment of the present invention, the long jump instruction that jumps to the patch function is written in the storage space before or after the function of the patch to be patched, and the instruction at the entry position of the patch function is modified to jump to the location.
  • the short jump instruction of the storage space the patch is activated by the execution of the instruction in the storage space to make the patch take effect, since the operation of the instruction at the entry point of the modified function is an atomic operation, that is, the instruction before the modification and the modified
  • the command length of the instruction is the same, so only one instruction can be modified, and no other instructions in the critical section need to be covered, thereby avoiding the prior art application of the online patch to the application, because the system adopts a complex instruction set, the jump instruction will cover the function entry.
  • the method of the embodiment of the present invention can ensure the security and reliability of the software online patch activation under the multi-thread condition, and the multiple instructions are used to cause the security and reliability of the patch activation in the multi-threaded scheduling mechanism. Will interrupt the business.
  • FIG. 1 is a schematic diagram of a patch activation principle in the prior art
  • FIG. 3a is a schematic structural diagram of a communication system according to an embodiment of the present invention.
  • FIG. 3b is a partial schematic diagram of a communication system according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of making and managing an online patch according to an embodiment of the present invention.
  • FIG. 5 is a schematic flowchart of a software online patch activation method according to an embodiment of the present invention
  • FIG. 6 is a schematic flowchart diagram of another software online patch activation method according to an embodiment of the present invention
  • FIG. 8 is a schematic diagram of a software online patch activation method according to an embodiment of the present invention
  • FIG. 8 is a pre-S201 of FIG. Schematic diagram of the method of leaving the intermediate zone;
  • Figure 9 is a schematic diagram showing the principle of a conventional application compilation process
  • Figure 10 is a schematic flow chart of another method for reserving the intermediate zone in S201 of Figure 6;
  • Figure 1 1 is a schematic diagram of a specific process of S2022 in Figure 10;
  • FIG. 12 is a schematic diagram of a contrast effect before and after inserting an intermediate area in an assembly file according to an embodiment of the present invention
  • FIG. 13 is a schematic structural diagram of a patch management apparatus according to an embodiment of the present invention.
  • the technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention.
  • the embodiments are a part of the embodiments of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
  • FIG. 3a and 3b are schematic diagrams showing the structure of a communication system according to an embodiment of the present invention.
  • the communication system of the embodiment of the present invention supports activation of an online patch of software in a multi-thread environment.
  • FIG. 3a includes three CPUs ( The CPU 1 1 , 1 2, 1 3 ), the CPU accesses the memory 30 through the bus 20.
  • the communication system of the embodiment of the present invention may include a CPU, that is, a single CPU communication system, and may also include multiple CPU, a multi-CPU (multi-core) communication system.
  • the communication system of the embodiment of the present invention includes at least one CPU and a memory, the CPU runs an operating system, and at least one application (also referred to as software) runs on the operating system, and the application is closed.
  • the patch management thread here may be a thread inside the patch to be patched, or may be independent of all threads to be patched, where:
  • the memory is loaded with an application including at least one function to be patched and a patch file including a patch function, wherein the storage location of the to-be-patched function has a storage capable of placing at least one long jump instruction before or after the entry position Space;
  • the storage space here, for example, may be within 128 bytes before or after the function entry position (also referred to as the function start position), specifically six bytes before the function entry position.
  • the patch management thread is configured to: during an operation of the application, locate an address of the patch function and an entry address of the to-be-picked function, and write in the storage space for jumping to a location a long jump instruction of the patch function, and modifying an instruction at the entry position of the to-be-picked function as a short jump instruction for jumping to the storage space; the service thread is used to execute to be hit
  • the short jump instruction at the entry position of the patch function jumps to the storage space, and jumps to the execution of the patch function by execution of the instruction in the storage space, thereby implementing the online patch.
  • instruction A the original instruction modified to the short jump instruction at the entry position of the patch function.
  • the patch management thread is specifically configured to: during an operation of the application, locate an address of the patch function and an entry address of the to-be-picked function, and write in the storage space. a long jump instruction for jumping to the patch function, or a reverse operation instruction for writing an operation instruction before the instruction A in the storage space and a long jump instruction for jumping to the patch function And modifying the instruction A having a length greater than or equal to two bytes at the entry position of the to-be-picked function into a short jump instruction for jumping to the storage space;
  • the instruction A is the first instruction at the entry position of the to-be-patched function, and is long If the degree is greater than or equal to two bytes, a long jump instruction for jumping to the patch function is written in the storage space; or, if the instruction A is a non-first entry at the entry position of the to-be-patched function
  • the instruction and having a length greater than or equal to two bytes, writes a reverse operation instruction of the operation instruction before the instruction A and a long jump instruction for jumping to the patch function in the storage space.
  • the patch management thread is specifically configured to: during an operation of the application, locate an address of the patch function and an entry address of the to-be-picked function, and in the storage space Writing a pop instruction pop and a long jump instruction for jumping to the patch function, and modifying a move instruction after the push instruction to push the entry position of the patch function to jump to the storage space Short jump instruction.
  • the communication system of the embodiment of the present invention further includes: a compiler (not shown in the figure), configured to: when compiling the patch to be patched, each of the patches to be patched
  • a compiler configured to: when compiling the patch to be patched, each of the patches to be patched
  • a storage space capable of placing at least one long jump instruction before or after the function entry position, where the storage space before or after the entry position of the function to be patched, and capable of placing at least one long jump instruction may be referred to as Middle area.
  • the compiler is specifically configured to: when compiling a program related function of the program to be patched to generate an assembly instruction according to a compilation option that controls a reservation of the storage space and a size of the storage space, Prior to outputting the assembly function name of the function, the compilation command specifies an initial instruction specifying the number of bytes to reserve a storage space (middle area) at which at least one long jump instruction can be placed.
  • the compiler is specifically configured to: after compiling the source file of the to-be-patched program to generate an assembly file, searching for a keyword string representing the function in the assembly file, and finding the representation in the assembly file
  • the first instruction of the specified number of bytes is inserted before or after the function entry position indicated by the function's keyword string to reserve a storage space (middle area) capable of placing at least one long jump instruction;
  • the assembly file is recompiled to generate a new assembly file, and the new The assembly file generates an object file, and the executable file to be patched is generated by a plurality of object file links; wherein the specified number of bytes represents the size of the storage space (middle area).
  • At least one long jump can be reserved before or after each function entry position of the to-be-patched program.
  • the storage space for the instruction For the specific working process involved in the compiler, reference may be made to the related content disclosed by the foregoing compiler, and details are not described herein again.
  • the patch management thread and at least one service thread may belong to the same process, that is, the patch operation can be completed in a single process; thus, all threads of the single process can share the access user state storage area (ie, process space).
  • the patch management thread writes a long jump instruction to the storage space (middle area) before or after the entry point of the function to be patched and can place at least one long jump instruction, and the entry point of the function to be patched The instruction is modified to jump to the short jump instruction of the storage space.
  • the patch management thread and the at least one service thread herein may also belong to different processes, for example: the patch management thread belongs to process A, and the at least one service thread belongs to process B.
  • the task is an image of the code running. From a system perspective, the task is the smallest unit of operation that competes for system resources. Tasks can use or wait for system resources such as CPU, I/O devices, and memory space, and run concurrently with them independently of other tasks. Under Linux and Win32 systems, the task corresponds to the concept of a thread.
  • the communication system of the embodiment of the present invention may specifically be a Linux X86 system, or a Linux X64 system, or a Unix-like system such as Solar is, a ix, or the like.
  • Linux X86 system including at least one CPU of x86 architecture, there is a Linux operation running on the CPU.
  • the system runs on the Linux operating system with at least one application (also referred to as software), and the application is associated with a patch management thread and at least one service thread (the specific functions are the same as above, and therefore are not described again).
  • the space write jumps to the long jump instruction of the patch function, and modifies the instruction at the entry position of the to-be-patched function to a short jump instruction that jumps to the storage space (middle area), when the patch is activated
  • the 205 is performed by the execution of the instruction in the intermediate area to make the patch take effect, since the operation of the instruction at the entry point of the modified function is an atomic operation, that is, the instruction before the modification and the instruction of the modified instruction have the same length, and thus only one instruction is modified. That is, there is no need to cover other instructions in the critical section, thereby avoiding the prior art activation of the online patch of the application software, because the system adopts a complex instruction set, the jump instruction will overwrite multiple instructions of the function entry, resulting in a multi-thread scheduling mechanism.
  • FIG. 4 is a schematic diagram of making and managing an online patch according to an embodiment of the present invention.
  • the patch making process is: after the online patch is created in the background using the patch tool, the patch source code is compiled into an object file, and The patch file is used to create an online patch file by copying the symbol file (absolute or relative positioning form) of the patch and the target file of the patch.
  • the patch management process is as follows: Read the online patch file (also known as the hot patch file) into the memory, load the patch into the patch area, and activate the activation.
  • the embodiments of the present invention are described in detail below with reference to the accompanying drawings:
  • FIG. 5 is a schematic flowchart of an online patch activation method according to an embodiment of the present invention.
  • the method may be applied to a communication system including at least one CPU and a memory, where the CPU runs a system 225, and the operation is performed.
  • the execution body of the method may be a patch management associated with the patch to be patched. Thread, where the method can include:
  • the address and location of the patch function are located.
  • the entry address of the patch function is read, wherein, specifically, the patch function address information is read from the array in the memory;
  • the patch function address information in the patch file is an absolute address
  • the patch function address information included in the patch file is directly stored in the allocated array in the memory.
  • the patch function address information in the patch file is a relative address (non-absolute address)
  • the absolute address of the patch function is calculated according to the relative address of the patch function, and the calculation result is stored in the memory. In the array.
  • the storage space can be, for example, the entry position of the function to be patched (also referred to as the function start position) Within 128 bytes before or after, it can be six bytes before the function entry position.
  • instruction A the original instruction modified to the short jump instruction at the entry position of the patch function.
  • the instruction A is the first instruction at the entry location of the function to be patched, and the length of the 250 is greater than or equal to two bytes.
  • the instruction A is a non-first instruction at the entry position of the to-be-picked function, and the length is greater than or equal to two bytes, and the intermediate area is written in the S1 02 for jumping to
  • the step of the long jump instruction of the patch function may specifically be: writing a reverse operation instruction of the operation instruction before the instruction A and a long jump instruction for jumping to the patch function in the intermediate area.
  • the instruction A is an instruction (ie, a second instruction) after the push instruction at the entry position of the function to be patched, and the operation instruction push before the instruction A is reversed.
  • the operation instruction is a pop instruction pop; correspondingly, the pop pop instruction and the long jump instruction for jumping to the patch function are written in the middle area; the push instruction at the entry position of the to be patched function
  • the instruction after the push ie, the second instruction
  • the intermediate area may be reserved before or after each function entry position of the program when the program to be patched is compiled. In an implementation manner, before all the positions of the to-be-picked function are entered or After the intermediate area is reserved, the following steps are included:
  • the compiling option for controlling the reservation of the intermediate zone and the size of the intermediate zone when compiling the function to be patched to generate an assembly instruction, outputting the 265 compiler option specifying byte before outputting the function name of the function
  • the initial number of instructions to reserve the middle zone It should be understood that the initial instruction here is used to pre-occupy the storage space, and correspondingly, the long jump instruction for jumping to the patch function is written in the intermediate area, and the original initial instruction in the storage space is modified to Long jump instruction (and Counter operation instruction).
  • the intermediate area is reserved before or after 270 of all the to-be-patched function entry positions by the following method, and specifically includes the following steps: displaying a keyword string of the function;
  • the assembly file inserted with the initial instruction is recompiled to generate a new assembly file, and the new assembly file is compiled to generate an object file, and multiple object file links are generated to generate an executable file to be patched.
  • FIG. 6 is a schematic flowchart of another online patch activation method according to an embodiment of the present invention.
  • the method may be applied to a communication system including at least one CPU and a memory, where the CPU runs an operating system, and the operation is performed.
  • the execution body of the method may be a patch management associated with the patch to be patched. Thread, where the method can include:
  • the intermediate area is reserved before the function entry position to ensure that the short jump shor t jmp instruction can be used to jump to the middle area.
  • the intermediate area is in front of the entry position of the function to be patched, and occupies six bytes (relative jump instruction). If an absolute jump instruction is used or applied to an X86-64 bit system, the address space of the reserved intermediate area should be corresponding.
  • the long jump instruction long jmp 315 herein is a 5-byte relative jump instruction, or an absolute jump instruction occupying more bytes.
  • the instructions written to the intermediate region are a pop instruction and a long jmp instruction.
  • the instruction written to the intermediate area may also be a push instruction, two pop instructions, and one long jm instruction; similarly, in another implementation, the instruction written in the intermediate area may also be Is two push instructions, three pop instructions and a long 320 jmp instruction; it should be understood that the number of pop instructions contained in the middle area and the push instructions contained in the critical section and the push instructions contained in the middle area The sum of the numbers is equal, in other words, the total stack instruction is equal to the total number of pop instructions.
  • the move instruction after the push instruction at the entry position of the function to be patched is modified into a short jump instruction shor t jump instruction for jumping to the middle area, Both the move instruction before modification and the modified shor t jmp instruction occupy 2 bytes, and the instruction length is the same.
  • the move instruction here is the second instruction at the entry position of the function to be patched.
  • the method of the embodiment of the present invention can ensure the security and reliability of the online patch taking effect because the operation of the second instruction at the entry point of the patching function is an atomic operation. Inter-area, and in the reserved intermediate area, write a long jump instruction that jumps to the patch function, and modify the second instruction that is after the push instruction of the entry position of the function to be patched into a jump To
  • the short jump instruction of the middle zone, the patch is activated by the intermediate zone when the patch is activated, and the operation of the second instruction of modifying the function entry position is an atomic operation, that is, the instruction before the modification and the modified
  • the command length of the instruction is the same, so only one instruction can be modified, and no other instructions in the critical section need to be covered, thereby avoiding the prior art application of the online patch to the application, because the system adopts a complex instruction set, the jump instruction will cover the function entry. Multiple instructions, resulting in a multi-threaded scheduling mechanism
  • the patch that exists under 345 activates the security and reliability risks (that is, when a thread executes to the critical section, the thread switching happens. If the online patch is activated at this time, the thread is switched back because the critical section of the original function has been If a new jump instruction is overwritten, an exception will occur in the program. Or, if a thread returns after processing the signal processing function (the return address of the signal is in the critical section), the critical section has been overwritten by the jump instruction, causing the program to fail. Therefore, the method of the embodiment of the present invention can ensure a multi-thread strip.
  • FIG. 8 a schematic flowchart of a method for reserving an intermediate area according to an embodiment of the present invention, is configured to reserve a middle area before or after each function entry position of the program when the patched program is compiled, where The method is applied to a system using the open source compiler g CC.
  • the operation of reserving the intermediate area in the embodiment of the present invention can be implemented by modifying the compiler code, and specifically includes the following steps:
  • the initial instruction here, for example, can be an empty instruction of null nul l, or an instruction of all 0s.
  • the step of writing the pop instruction and the long jump instruction long jmp in the intermediate area in S203 in FIG. 6 is specifically: modifying the initial instruction into a pop instruction and a long jump instruction long jm P o
  • FIG. 9 is a schematic diagram of a conventional application compilation process.
  • the conventional compilation process includes: Compiling a source file (.c file) into a target file (.0 file) by a compiler. , ie binary files), then link multiple object files into executable files.
  • FIG. 10 is a schematic flowchart of still another method for reserving an intermediate area according to an embodiment of the present invention, which supports saving an intermediate area before or after all function entry positions when a patched program is compiled.
  • the operation of reserving the intermediate area can realize the reservation of the intermediate area by modifying the assembly file generated during the compilation process.
  • This method is not only applicable to applications compiled with the open source compiler gcc, but also to applications compiled with other compilers that are not open source, where the method is specifically described in
  • S202 compiles the source file (.c file) to be patched into an assembly file (.s file;); since it is a prior art, it will not be described here.
  • S2022 Reserve a middle area before all function entry positions: look up a keyword string representing a function in the compiled assembly file, and find the function entry position indicated by the keyword string 380 of each representation function. Before, insert the initial instruction of the specified number of bytes to reserve the intermediate area;
  • the initial instruction here can be, for example, a null instruction of a null nul, or an instruction of all zeros.
  • the size of the reserved intermediate area is indicated by the specified number of bytes.
  • S2025 Linking multiple target files to generate an executable file to be patched. Since it is a prior art, it will not be described here. It should be noted that the executable file generated here is the patch to be patched in the middle area before all the function entry positions.
  • the initial instruction herein is specifically 395 all 0 instructions 0 x 90.
  • the specified number of bytes is specifically 6 bytes of byte, where Figure 12a is a schematic diagram of the operation before inserting a 6-byte all-zero instruction before the found function entry position; Figure 12b is inserted before the found function entry position Schematic diagram of the operation of a full-zero instruction of 6 bytes.
  • the keyword string representing the function is Slfunction, and as shown in FIG. 12, two Sfunct ions are found.
  • the patch management device of the embodiment of the present invention can be understood as the patch management thread, and the patch management thread according to the embodiment of the present invention can be expressed in a patch management manner independent of various applications.
  • the program, or the thread inside the application to be patched, as shown in FIG. 13 the patch management apparatus of this embodiment includes:
  • An address locating unit 301 configured to locate and respond to the application of the application to be patched
  • a long jump instruction unit 302 configured to write, in the intermediate area, a long jump instruction for jumping to the patch function based on an address of the patch function and an entry address of the to-be-picked function, where
  • the middle area is a storage space before or after the entry point of the function to be patched, and at least one long jump instruction can be placed;
  • the storage space (middle area) here can be, for example, the entry point 420 of the function to be patched (also called Within 128 bytes before or after the function start position, it can be six bytes before the function entry position.
  • a short jump instruction unit 303 configured to modify an instruction at an entry position of the function to be patched to jump to a short jump instruction of the intermediate area, so that after the short jump instruction is executed, jump to the The intermediate area jumps to the patch function execution by execution of the instruction in the intermediate area.
  • instruction A the original instruction modified to the short jump instruction at the entry position of the function to be patched is referred to as instruction A.
  • the instruction A is the first instruction at the entry location of the function to be patched, and the length is greater than or equal to two bytes.
  • the instruction A is a non-first instruction at the entry position of the function to be patched, 430 and the length is greater than or equal to two bytes, and correspondingly, the long jump instruction unit 302 is specifically configured to be based on the patch.
  • the address of the function and the entry address of the function to be patched, the reverse operation instruction of the operation instruction before the instruction to be modified (ie, instruction A) and the long jump for jumping to the patch function are written in the intermediate area An instruction, wherein the intermediate area is a storage space that is located before or after the entry point of the function to be patched, and can place at least one long jump instruction;
  • the short jump instruction unit 303 is specifically configured to modify a non-header instruction whose length at the entry position of the to-be-picked function is greater than or equal to two bytes to a short jump instruction that jumps to the middle area, so that After the short jump instruction is executed, the jump to the intermediate area is performed by the execution of the intermediate area instruction to jump to the patch function execution.
  • the specific working process involved in all the units may refer to the above.
  • the embodiment of the present invention further provides a communication system, where the communication system includes at least one processor core and a memory, the processor core runs an operating system, and the operating system runs at least one application program.
  • the application is associated with a patch management thread and at least one business thread, where:
  • the memory is loaded with an application that includes at least one function to be patched and a patch file that includes a patch function, where the entry position of the to-be-patched function has at least one long jump instruction before or after the entry position. storage;
  • the patch management thread is configured to: during an operation of the application, locate an address of the patch function and an entry address of the to-be-picked function, and write in the storage space for jumping 450 to Determining a long jump instruction of the patch function, and modifying an instruction at the entry position of the to-be-picked function to a short jump instruction for jumping to the storage space;
  • the service thread is configured to execute a short jump instruction to the entry position of the to-be-patched function, jump to the storage space, and jump to execution by the execution of the instruction in the storage space to the patch function.
  • the processor in the embodiment of the present invention includes, but is not limited to, a single core processor or a 455 multi-core processor.
  • the processor core mentioned in the embodiment of the present invention includes but is not limited to: a CPU.
  • DSP digital signal processor
  • MPU Micro Processor Unit
  • the intermediate area is reserved, and a long jump instruction jumping to the patch function is written in the reserved intermediate area, and an instruction at the entry position of the to-be-patched function is modified to jump to the middle
  • the short jump instruction of the area, the patch is activated by the intermediate area when the patch is activated, and the operation of the instruction at the entry position of the modified function is an atomic operation, that is, the instruction length before the modification and the instruction length of the modified instruction are the same. Therefore, only one instruction can be modified, and it is not necessary to cover other instructions in the critical section, thereby avoiding
  • the method of the embodiment of the present invention can ensure the security and reliability of software online patch activation under multi-thread conditions. Sex, without disrupting business.
  • a person skilled in the art can understand that all or part of the process of implementing the above embodiment method can be completed by a computer program to instruct related hardware, and the program can be stored in 475
  • a computer readable storage medium, the program, when executed, may include the flow of an embodiment of the methods as described above.
  • the storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Acces s Memory (RAM).

Description

说 明 书
在线补丁的激活方法、 装置及系统
技术领域 本发明涉及计算机技术领域, 具体涉及一种在线补丁的激活方法、 装置 及系统。 背景技术 在线补丁是指程序运行中不重启程序而生效的补丁, 广泛应用于各类软 件。 参见图 1, 激活在线补丁的基本原理是将要原函数(即待打补丁的函数) 的入口处的指令替换为跳转指令, 然后通过替换的跳转指令将调用原函数的 程序跳转到的补丁函数中执行。 随着 L i nux X86系统在电信领域的广泛应用, 同样要求对 Linux系统中的应用软件能够在线打补丁, 但由于 X86 系统的指 令特点以及 Linux 的调度方式, 使得简单的将被替换函数的入口处指令改为 跳转指令的补丁激活方式变得不完全可靠, 不能满足电信软件对可靠性的要 求。
参见图 2, 在 Linux X86系统中, 无条件跳转指令占 5个字节, 激活在线 补丁时绝大多数情况下都会覆盖原函数入口处的 3条指令, 称原函数中这 3 条指令占用的 5 个字节的区域为临界区。 如果激活在线补丁时直接将原函数 入口处的指令替换为跳转指令, 则当进程中有多个线程时, 有可能出现某线 程执行到临界区处 (如执行到第一条或第二条指令) 时刚好发生线程切换的 情况, 若此时激活在线补丁, 该线程切换回来后由于原函数的临界区代码已 被新的跳转指令覆盖, 程序便会发生异常。 现有技术一般使用 Pannus补丁技术, 具体包括以下步骤:
( 1 )使用函数 pt race将原函数的进程暂停;
( 2 )检查原函数所有线程的 EIP (extended ins t ruct ion pointer , 指 令指针寄存器)值是否在临界区;
( 3 )如果没有线程的 EIP值在临界区,则在补丁函数入口写入跳转指令, 恢复进程的执行;
( 4 )如果有线程的 EIP值在临界区, 则恢复进程执行一段时间, 重新暂 停进程进行检查;
( 5 )检查若干次(可自定义, 如 10 次)后, 如果还不能激活补丁, 则 返回激活补丁失败。
由于 Pannus先暂停原函数进程,再检查所有线程的 EIP值是否在临界区, 因此, 可以在一定程度上避免因直接写入而发生的程序异常。
发明人在实现本发明过程中, 发现现有技术中:
替换函数前只检查当前线程 EIP值是否在临界区, 一旦有线程是在信号 处理函数中, 信号的返回地址在临界区内, 则在线程处理完信号处理函数后 返回时, 由于临界区已被跳转指令覆盖, 这时将会导致程序出错, 因此这种 现有技术方案仍然不能保证激活补丁时安全可靠。
发明内容 本发明实施例在于提供一种软件在线补丁的激活方法及系统, 以提高应 用软件在线补丁激活时的安全性和可靠性。
本发明实施例是通过以下技术方案实现的: 一种在线补丁激活方法, 包括如下步骤:
定位补丁函数的地址和待打补丁函数的入口地址;
基于所述补丁函数的地址和所述待打补丁函数的入口地址, 在中间区写 入用于跳转到所述补丁函数的长跳转指令, 其中所述中间区为处于待打补丁 函数入口位置前或后, 且能放置至少一条长跳转指令的存储空间;
将待打补丁函数入口位置处的指令修改为跳转到所述中间区的短跳转指 令, 使得所述短跳转指令被执行后, 跳转到所述中间区, 通过所述中间区指 令的执行跳转到所述补丁函数执行。
以及, 一种通信系统,所述通信系统包括至少一个 CPU和内存,所述 CPU 上运行有操作系统, 所述操作系统之上运行有至少一种应用程序, 所述应用 程序关联有补丁管理线程和至少一个业务线程, 其中:
所述内存中载入有包含至少一个待打补丁函数的应用程序和包含补丁函 数的补丁文件, 其中, 所述待打补丁函数的入口位置前或后具有能放置至少 一条长跳转指令的存储空间;
所述补丁管理线程用于在所述应用程序的运行过程中, 定位所述补丁函 数的地址和所述待打补丁函数的入口地址, 并在所述存储空间写入用于跳转 到所述补丁函数的长跳转指令, 以及将所述待打补丁函数入口位置处的指令 修改为用于跳转到所述存储空间的短跳转指令;
所述业务线程用于执行到待打补丁函数入口位置处的短跳转指令, 跳转 到所述存储空间, 通过所述存储空间中指令的执行跳转到所述补丁函数执行。
以及, 一种补丁管理装置, 所述装置包括:
地址定位单元, 用于在待打补丁应用程序的运行过程中, 定位与该应用 程序关联的补丁函数的地址和待打补丁函数的入口地址; 长跳转指令单元, 用于基于所述补丁函数的地址和所述待打补丁函数的 入口地址, 在中间区写入用于跳转到所述补丁函数的长跳转指令, 其中所述 中间区为处于待打补丁函数入口位置前或后, 且能放置至少一条长跳转指令 的存储空间;
短跳转指令单元, 用于将待打补丁函数入口位置处的指令修改为跳转到 所述中间区的短跳转指令, 使得所述短跳转指令被执行后, 跳转到所述中间 区, 通过所述中间区中指令的执行跳转到所述补丁函数执行。
以及, 一种通信系统, 所述通信系统包括至少一个处理器核和内存, 所 述处理器核上运行有操作系统, 所述操作系统之上运行有至少一种应用程序, 所述应用程序关联有补丁管理线程和至少一个业务线程, 其中:
所述内存中载入有包含至少一个待打补丁函数的应用程序和包含补丁函 数的补丁文件, 其中, 所述待打补丁函数的入口位置前或后具有能放置至少 一条长跳转指令的存储空间;
所述补丁管理线程用于在所述应用程序的运行过程中, 定位所述补丁函 数的地址和所述待打补丁函数的入口地址, 并在所述存储空间写入用于跳转 到所述补丁函数的长跳转指令, 以及将所述待打补丁函数入口位置处的指令 修改为用于跳转到所述存储空间的短跳转指令;
所述业务线程用于执行到待打补丁函数入口位置处的短跳转指令, 跳转 到所述存储空间, 通过所述存储空间中指令的执行跳转到所述补丁函数执行。 可见, 本发明实施例通过在待打补丁程序的函数前或后的存储空间写入 跳转到补丁函数的长跳转指令, 以及将待打补丁函数入口位置处的指令修改 为跳转到所述存储空间的短跳转指令, 补丁激活时通过该存储空间中指令的 执行进行跳转使补丁生效, 由于修改函数入口位置处的指令的操作是原子操 作, 即修改前的指令和修改后的指令的指令长度相同, 因而仅修改一条指令 即可, 无需覆盖临界区其它指令, 从而避免了现有技术中对应用软件在线补 丁激活时, 因系统采用复杂指令集, 跳转指令会覆盖函数入口的多条指令, 而导致多线程调度机制下所存在的补丁激活安全性和可靠性隐患, 因此, 本 发明实施例方法可以保证多线程条件下软件在线补丁激活的安全性和可靠 性, 且不会中断业务。 附图说明 为了更清楚地说明本发明实施例或现有技术中的技术方案, 下面将对实 施例或现有技术描述中所需要使用的附图作简单地介绍, 显而易见地, 下面 描述中的附图仅仅是本发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动性的前提下, 还可以根据这些附图获得其它的附图。
图 1为现有技术中的补丁激活原理示意图;
图 2为现有技术中的临界区示意图;
图 3a为本发明实施例的通信系统的一种结构示意图;
图 3b为本发明实施例的通信系统的局部逻辑示意图;
图 4为本发明实施例的在线补丁的制作与管理示意图;
图 5为本发明实施例的一种软件在线补丁激活方法的流程示意图; 图 6为本发明实施例的另一种软件在线补丁激活方法的流程示意图; 图 Ί为本发明具体实施例中的软件在线补丁激活方法的原理示意图; 图 8为图 6中 S201的一种预留中间区的方法流程示意图;
图 9为一种传统的应用程序的编译过程的原理示意图;
图 1 0为图 6中 S201的又一种预留中间区的方法流程示意图;
图 1 1为图 1 0中 S2022的一种具体流程示意图;
图 12 为本发明实施例的在汇编文件中插入中间区的前后对比效果示意 图;
图 1 3为本发明实施例的一种补丁管理装置的结构示意图。 具体实施方式 为使本发明实施例的目的、 技术方案和优点更加清楚, 下面将结合本发 明实施例中的附图, 对本发明实施例中的技术方案进行清楚、 完整地描述, 显然, 所描述的实施例是本发明一部分实施例, 而不是全部的实施例。 基于 本发明中的实施例, 本领域普通技术人员在没有作出创造性劳动前提下所获 得的所有其他实施例, 都属于本发明保护的范围。
请参阅图 3a和 3b, 为本发明实施例的通信系统的结构示意图, 本发明实 施例通信系统支持多线程环境下的软件在线补丁的激活, 需要说明的是, 图 3a中包括三个 CPU ( CPU1 1 , 1 2, 1 3 ) , 所述 CPU通过总线 20访问内存 30, 应当理解的是, 本发明实施例的通信系统中可以包括一个 CPU , 即单 CPU的通 信系统, 也可以包括多个 CPU , 即多 CPU (多核) 的通信系统。 即本发明实施 例的通信系统, 包括至少一个 CPU和内存, 所述 CPU上运行有操作系统, 所 述操作系统之上运行有至少一种应用程序 (亦称为软件) , 所述应用程序关 联有补丁管理线程和至少一个业务线程, 需要说明的是, 这里的补丁管理线 程可以是待打补丁程序内部的线程, 也可以是独立于所有待打补丁程序之外 的线程, 其中:
所述内存中载入有包含至少一个待打补丁函数的应用程序和包含补丁函 数的补丁文件, 其中, 所述待打补丁函数的入口位置前或后具有能放置至少 一条长跳转指令的存储空间; 这里的存储空间,例如可以是函数入口位置(亦 可称为函数起始位置)前或后的 128 字节内, 具体可以是函数入口位置前的 六个字节。
所述补丁管理线程, 用于在所述应用程序的运行过程中, 定位所述补丁 函数的地址和所述待打补丁函数的入口地址, 并在所述存储空间写入用于跳 转到所述补丁函数的长跳转指令, 以及将所述待打补丁函数入口位置处的指 令修改为用于跳转到所述存储空间的短跳转指令; 所述业务线程, 用于执行 到待打补丁函数入口位置处的短跳转指令, 跳转到所述存储空间, 通过所述 存储空间中指令的执行跳转到所述补丁函数执行, 从而实现在线补丁生效。
为了下文描述方便, 这里将待打补丁函数入口位置处被修改为短跳转指 令的原指令称作指令 A。
在一种实现方式下, 所述补丁管理线程具体用于在所述应用程序的运行 过程中, 定位所述补丁函数的地址和所述待打补丁函数的入口地址, 在所述 存储空间写入用于跳转到所述补丁函数的长跳转指令, 或者, 在所述存储空 间写入处于指令 A前的操作指令的反操作指令和用于跳转到所述补丁函数的 长跳转指令, 以及将待打补丁函数入口位置处的长度大于或等于两字节的指 令 A修改为用于跳转到所述存储空间的短跳转指令;
具体的, 如果所述指令 A为待打补丁函数入口位置处的首条指令, 且长 度大于或等于两字节, 则在所述存储空间写入用于跳转到所述补丁函数的长 跳转指令; 或者, 如果所述指令 A为待打补丁函数入口位置处的非首条指令, 且长度大于或等于两字节, 则在所述存储空间写入处于指令 A前的操作指令 的反操作指令和用于跳转到所述补丁函数的长跳转指令。
在一种具体实现方式下, 所述补丁管理线程具体用于在所述应用程序的 运行过程中, 定位所述补丁函数的地址和所述待打补丁函数的入口地址, 并 在所述存储空间写入出栈指令 pop和用于跳转到所述补丁函数的长跳转指令, 以及将待打补丁函数入口位置的入栈指令 push之后的 move指令修改为用于 跳转到所述存储空间的短跳转指令。
本发明的一种实施例中, 本发明实施例的通信系统进一步包括: 编译器 (图中未示意出), 用于在对待打补丁程序进行编译时, 在所述待打补丁程序 的每个函数入口位置前或后预留能放置至少一条长跳转指令的存储空间, 这 里的处于待打补丁函数的入口位置前或后, 且能放置至少一条长跳转指令的 存储空间可以被称作中间区。
在一种具体实现方式下, 所述编译器具体用于: 根据控制所述存储空间 的预留及所述存储空间的大小的编译选项, 编译待打补丁的程序相关的函数 生成汇编指令时, 在输出函数的汇编函数名之前, 输出所述编译选项指定字 节数的初始指令以预留能放置至少一条长跳转指令的存储空间 (中间区)。
在另一种具体实现方式下, 所述编译器具体用于: 将待打补丁程序的源 文件编译生成汇编文件后, 查找所述汇编文件中表示函数的关键字字符串, 并在找到的表示函数的关键字字符串所指示的函数入口位置的前或后, 插入 指定字节数的初始指令以预留能放置至少一条长跳转指令的存储空间 (中间 区); 对插入有前述初始指令的汇编文件重新编译生成新的汇编文件, 并将新 的汇编文件生成目标文件, 由多个目标文件链接生成待打补丁程序的可执行 文件; 其中, 所述指定字节数表示所述存储空间 (中间区) 的大小。
本发明的另一种实施例下, 本发明实施例的通信系统中, 所述操作系统 时, 在所述待打补丁程序的每个函数入口位置前或后预留能放置至少一条长 跳转指令的存储空间。 所述编译程序所涉及的具体工作过程, 可以参考前述 编译器揭露的相关内容, 在此不再赘述。
需要说明的是, 这里的补丁管理线程和至少一个业务线程可以属于同一 个进程, 即补丁操作能在单进程内完成; 这样, 单进程的所有线程能共享访 问用户态存储区 (即进程空间), 在单进程内, 补丁管理线程将长跳转指令写 入待打补丁函数入口位置前或后且能放置至少一条长跳转指令的存储空间 (中间区), 以及待打补丁函数入口位置处的指令修改为跳转到所述存储空间 的短跳转指令。
另一种实现下, 这里的补丁管理线程和所述至少一个业务线程也可以分 别属于不同的进程, 例如: 补丁管理线程属于进程 A, 所述至少一个业务线程 属于进程 B。
需要说明的是, 任务是代码运行的一个映象, 从系统的角度看, 任务是 竟争系统资源的最小运行单元。 任务可以使用或等待 CPU、 I/O设备及内存空 间等系统资源, 并独立于其它任务, 与它们一起并发运行。 在 Linux和 Win32 系统下, 任务对应线程 ( thread ) 的概念。
应当理解的是, 本发明实施例通信系统具体可以是 Linux X86 系统, 或 者, Linux X64系统, 也可以是 Solar i s、 a ix等类 Unix系统等等。 例如, 在 Linux X86系统下, 包括至少一个 x86架构的 CPU, CPU上运行有 L inux操作 系统, 所述 Linux操作系统之上运行有至少一种应用程序 (亦称为软件) , 200 所述应用程序关联有补丁管理线程和至少一个业务线程(具体功能同上, 故 不再赘述) 。 空间写入跳转到所述补丁函数的长跳转指令, 以及将待打补丁函数入口位置 处的指令修改为跳转到所述存储空间 (中间区) 的短跳转指令, 补丁激活时
205 通过该中间区中指令的执行进行跳转使补丁生效, 由于修改函数入口位置处 的指令的操作是原子操作, 即修改前的指令和修改后的指令的指令长度相同, 因而仅修改一条指令即可, 无需覆盖临界区其它指令, 从而避免了现有技术 中对应用软件在线补丁激活时, 因系统采用复杂指令集, 跳转指令会覆盖函 数入口的多条指令, 而导致多线程调度机制下所存在的补丁激活安全性和可
210 靠性隐患 (即某线程执行到临界区 (即待打补丁的函数入口处的指令区域) 处时刚好发生线程切换的情况, 若此时激活在线补丁, 该线程切换回来后由 于原函数的临界区已被新的跳转指令覆盖, 程序便会发生异常; 或者, 有线 程处理完信号处理函数后返回 (信号的返回地址在临界区内) 时, 由于临界 区已被跳转指令覆盖, 导致程序出错) , 因此, 本发明实施例方法可以保证
215 多线程条件下软件在线补丁激活的安全性和可靠性, 且不会中断业务。
请参阅图 4,为本发明实施例在线补丁的制作与管理示意图,如图 4所示, 补丁制作过程为: 在线补丁在后台使用补丁工具制作完毕后, 补丁源代码被 编译成目标文件, 并通过补丁制作工具将待打补丁程序的符号文件 (绝对或 相对定位形式)和补丁程序的目标文件制作生成在线补丁文件。
220 补丁管理过程为: 读取上述在线补丁文件(亦称为热补丁文件)到内存, 加载补丁到补丁区, 并激活生效。 下面结合附图来详细描述本发明实施例:
请参阅图 5, 为本发明实施例的一种在线补丁激活方法的流程示意图, 该 方法可以应用于包括至少一个 CPU和内存的通信系统, 所述 CPU上运行有操 225 作系统, 所述操作系统之上运行有至少一种应用程序 (亦称为软件) , 所述 应用程序关联有补丁管理线程和至少一个业务线程, 具体的, 该方法的执行 主体可以是待打补丁程序关联的补丁管理线程, 其中该方法可以包括:
S101、 定位补丁函数的地址和待打补丁函数的入口地址;
具体的, 在待打补丁程序的运行过程中, 定位所述补丁函数的地址和所
230 述待打补丁函数的入口地址, 其中, 具体的是, 从内存中的数组中读取补丁 函数地址信息;
需要说明的是, 如图 4 所示, 如果补丁文件中的补丁函数地址信息是绝 对地址, 在加载补丁的过程中, 直接将补丁文件中包含的补丁函数地址信息 存入内存中分配好的数组中;
235 如果补丁文件中的补丁函数地址信息是相对地址(非绝对地址) , 在加 载补丁的过程中, 根据补丁函数的相对地址计算得到补丁函数的绝对地址, 并将计算结果存入内存中分配好的数组中。
5102、 基于所述补丁函数的地址和所述待打补丁函数的入口地址, 在中 间区写入用于跳转到所述补丁函数的长跳转指令, 其中所述中间区为处于待
240 打补丁函数入口位置前或后, 且能放置至少一条长跳转指令的存储空间; 这里的存储空间 (中间区) 例如可以是待打补丁函数入口位置 (亦可称 为函数起始位置)前或后的 128 字节内, 具体可以是函数入口位置前的六个 字节。
5103、 将待打补丁函数入口位置处的指令修改为跳转到所述中间区的短 245 跳转指令, 使得所述短跳转指令被执行后, 跳转到所述中间区, 通过中间区 中指令的执行跳转到补丁函数执行, 从而实现在线补丁生效。
为了下文描述方便, 这里将待打补丁函数入口位置处被修改为短跳转指 令的原指令称作指令 A。
在一种实现方式下, 指令 A为待打补丁函数入口位置处的首条指令, 且 250 长度大于或等于两字节。
在另一种实现方式下, 指令 A为待打补丁函数入口位置处的非首条指令, 且长度大于或等于两字节, 则 S 1 02中所述在中间区写入用于跳转到所述补丁 函数的长跳转指令的步骤具体可以为: 在所述中间区写入处于指令 A前的操 作指令的反操作指令和用于跳转到所述补丁函数的长跳转指令。
255 本发明的一种具体实施例中, 指令 A为将待打补丁函数入口位置处的入 栈指令 push之后的指令(即第二条指令),所述处于指令 A前的操作指令 push 的反操作指令为出栈指令 pop; 相应的, 在所述中间区写入出栈 pop指令和用 于跳转到所述补丁函数的长跳转指令; 将待打补丁函数入口位置处的入栈指 令 push之后的指令(即第二条指令)修改为跳转到所述中间区的短跳转指令。 260 其中, 可以在待打补丁的程序编译时在所述程序的每个函数入口位置前 或后预留中间区, 在一种实现方式下, 通过如下方法在所有待打补丁函数入 口位置前或后预留中间区, 具体包括如下步骤:
根据控制所述中间区的预留及所述中间区的大小的编译选项, 编译待打 补丁程序的函数生成汇编指令时, 在输出函数的汇编函数名之前, 输出所述 265 编译选项指定字节数的初始指令以预留中间区。 应当理解的是, 这里的初始 指令是用于预先占用存储空间的, 相应的, 在中间区写入用于跳转到所述补 丁函数的长跳转指令即将存储空间中原有的初始指令修改为长跳转指令(和 反操作指令)。
在另一种实现方式下, 通过如下方法在所有待打补丁函数入口位置前或 270 后预留中间区, 具体包括如下步骤: 示函数的关键字字符串;
在找到的表示函数的关键字字符串所指示的函数入口位置的前或后, 插 入指定字节数的初始指令以预留中间区; 其中, 所述指定字节数表示所述中 275 间区的大小;
对插入有所述初始指令的汇编文件重新编译生成新的汇编文件, 并将新 的汇编文件编译生成目标文件, 由多个目标文件链接生成待打补丁程序的可 执行文件。
280 空间写入跳转到所述补丁函数的长跳转指令, 以及将待打补丁函数入口位置 处的指令修改为跳转到所述存储空间 (中间区) 的短跳转指令, 补丁激活时 通过该中间区中指令的执行进行跳转使补丁生效, 由于修改函数入口位置处 的指令的操作是原子操作, 即修改前的指令和修改后的指令的指令长度相同, 因而仅修改一条指令即可, 无需覆盖临界区其它指令, 从而避免了现有技术
285 中对应用软件在线补丁激活时, 因系统采用复杂指令集, 跳转指令会覆盖函 数入口的多条指令, 而导致多线程调度机制下所存在的补丁激活安全性和可 靠性隐患 (即某线程执行到临界区 (即待打补丁的函数入口处的指令区域) 处时刚好发生线程切换的情况, 若此时激活在线补丁, 该线程切换回来后由 于原函数的临界区已被新的跳转指令覆盖, 程序便会发生异常; 或者, 有线
290 程处理完信号处理函数后返回 (信号的返回地址在临界区内) 时, 由于临界 区已被跳转指令覆盖, 导致程序出错) , 因此, 本发明实施例方法可以保证 多线程条件下软件在线补丁激活的安全性和可靠性, 且不会中断业务。 请参阅图 6, 为本发明实施例的另一种在线补丁激活方法的流程示意图, 295 该方法可以应用于包括至少一个 CPU和内存的通信系统, 所述 CPU上运行有 操作系统, 所述操作系统之上运行有至少一种应用程序 (亦称为软件) , 所 述应用程序关联有补丁管理线程和至少一个业务线程, 具体的, 该方法的执 行主体可以是待打补丁程序关联的补丁管理线程, 其中该方法可以包括:
S201、 在一应用程序编译时, 在所述应用程序的每个函数入口位置前或
300 后预留中间区;
较优的, 在函数入口位置前预留中间区, 以保证使用短跳转 shor t jmp 指令能够跳转到中间区。 如图 Ί 所示, 在本发明具体实施例中, 所述中间区 处于待打补丁函数入口位置前, 且占用六个字节 (相对跳转指令)。 如果使用 绝对跳转指令或者是应用于 X86-64位系统, 则预留中间区的地址空间应相应
305 扩大。
S202、 当该应用程序需要在线打补丁时, 在该应用程序的运行过程中加 载包括补丁函数的补丁文件到所述内存中, 并将补丁函数地址信息存入内存; 具体是, 将补丁文件中包含的补丁函数地址信息存入内存中的数组或经 计算后存入内存中的数组;
310 S203、 当触发补丁激活的事件发生时, 基于所述待打补丁函数的入口地 址和从内存中读取的补丁函数地址信息, 在中间区写入待打补丁函数入口位 置处的 push指令的反操作指令 pop指令(即出栈指令, 占用 1个字节)和用 于跳转到相应补丁函数的长跳转指令 l ong jmp; 如图 7所示, 在本发明具体实施例中, 这里的长跳转指令 long jmp可以 315 是 5字节的相对跳转指令, 或者占用更多字节的绝对跳转指令。
如图 7所示, 在本发明具体实施例中, 写入中间区的指令为一个 pop指 令和一个 long jmp指令。 在另一种实现方式下, 写入中间区的指令也可以是 一个 push指令, 两个 pop指令和一个 long jm 指令; 同理, 在又一种实现 方式下,写入中间区的指令也可以是两个 push指令,三个 pop指令和一个 long 320 jmp指令; 应当理解的是, 中间区中包含的 pop指令的个数与临界区中包含的 push指令和中间区中包含的 push指令的个数之和相等,换言之, 即总的入栈 指令和总的出栈指令个数相当。
S204、 将待打补丁函数入口位置处的 push指令(即入栈指令)之后的指 令修改为用于跳转到该中间区的短跳转指令 short jump指令(其占用 2字节), 325 使得所述 shor t jump指令被执行后跳转到所述中间区, 通过中间区中指令的 执行跳转到补丁函数执行, 从而实现在线补丁的激活 /生效。
需要说明的是, 在又一种实现方式下, 如果待打补丁函数的入口位置处 待修改为短跳转指令的原指令为待打补丁函数的入口位置处的首条指令且指 令长度大于或等于 2个字节, 则 S203中可以在中间区写入用于跳转到补丁函 330 数的长跳转指令 long jm 即可。
如图 Ί所示,在本发明具体实施例中,将待打补丁函数入口位置处的 push 指令之后的 move指令修改为用于跳转到所述中间区的短跳转指令 shor t jump 指令, 修改前的 move指令与修改后的 shor t jmp指令均占用 2字节, 指令长 度相同, 这里的 move指令即待打补丁函数入口位置处的第二条指令。 由于修 335 改待打补丁函数入口位置处的第二条指令的操作是原子操作, 本发明实施例 方法可以保证在线补丁生效的安全性和可靠性。 间区, 并在所述预留的中间区写入跳转到所述补丁函数的长跳转指令, 以及 将待打补丁函数入口位置的 push指令之后的指令即第二条指令修改为跳转到
340 所述中间区的短跳转指令, 补丁激活时通过该中间区进行跳转使补丁生效, 由于修改函数入口位置的第二条指令的操作是原子操作, 即修改前的指令和 修改后的指令的指令长度相同, 因而仅修改一条指令即可, 无需覆盖临界区 其它指令, 从而避免了现有技术中对应用软件在线补丁激活时, 因系统采用 复杂指令集, 跳转指令会覆盖函数入口的多条指令, 而导致多线程调度机制
345 下所存在的补丁激活安全性和可靠性隐患 (即某线程执行到临界区处时刚好 发生线程切换的情况, 若此时激活在线补丁, 该线程切换回来后由于原函数 的临界区已被新的跳转指令覆盖, 程序便会发生异常; 或者, 有线程处理完 信号处理函数后返回 (信号的返回地址在临界区内) 时, 由于临界区已被跳 转指令覆盖, 导致程序出错) , 因此, 本发明实施例方法可以保证多线程条
350 件下软件在线补丁激活的安全性和可靠性, 且不会中断业务。
请参阅图 8, 为本发明实施例的一种预留中间区的方法的流程示意图, 支 持在被打补丁的程序编译时在该程序的每个函数入口位置前或后预留中间 区, 其中该方法应用于使用开源编译器 g C C 的系统中, 本发明实施例预留中 间区的操作可以通过对编译器代码的修改实现, 具体包括如下步骤:
355 S201 在用于待打补丁程序编译的编译器的代码中添加编译选项, 所述 编译选项用于控制中间区的预留及中间区的大小;
S2012、 根据所述编译选项, 编译待打补丁程序的函数生成汇编指令时, 在输出函数的汇编函数名之前, 输出所述编译选项指定字节数的初始指令以 预留中间区。 360 这里的初始指令, 例如可以是全空 nul l 的空指令, 或全 0 的指令。
相应的, 图 6中 S203中在中间区写入 pop指令和长跳转指令 long jmp的 步骤具体为: 将初始指令修改为 pop指令和长跳转指令 long jmP o
需要说明的是,在开源编译器 gcc的系统的一般版本中,可以在 Varasm. c 文件中的 as semb le, s tar t -funct ion中输出函数 ref i x到汇编文件的代码之 365 前, 增加向汇编文件输出所述编译选项指定字节数的初始指令的操作。 请参阅图 9, 为一种传统的应用程序的编译过程的原理示意图, 如图 9所 示, 传统的编译过程包括: 通过编译器将源文件 (. c文件)编译成目标文件 ( . 0文件, 即二进制文件), 再将多个目标文件链接成可执行文件。
370 请参阅图 10,为本发明实施例的又一种预留中间区的方法的流程示意图, 支持在被打补丁的程序编译时在所有函数入口位置前或后预留中间区, 本发 明实施例预留中间区的操作可以通过修改编译过程中产生的汇编文件来实现 中间区的预留。 该方法不仅适用于使用开源编译器 gcc编译的应用程序, 而 且适用于使用不开源的其它编译器编译的应用程序, 其中该方法具体介绍在
375 函数入口位置前预留中间区, 包括如下步骤:
S202 将待打补丁程序的源文件( . c文件 )编译成汇编文件( . s文件;); 由于为现有技术, 故这里不再赘述。
S2022、 在所有函数入口位置前预留中间区: 查找所述编译生成的汇编文 件中表示函数的关键字字符串, 并在找到的每个表示函数的关键字字符串所 380 指示的函数入口位置前, 插入指定字节数的初始指令以预留中间区;
这里的初始指令, 例如可以是全空 nul l的空指令, 或全 0的指令。 这里 以指定字节数来表示预留的中间区的大小。 S2023、 对插入有所述初始指令的汇编文件重新编译生成新的汇编文件; 由于为现有技术, 故这里不再赘述。
385 S2024、 将所述新的汇编文件编译生成目标文件; 由于为现有技术, 故这 里不再赘述。
S2025、 将多个目标文件链接生成待打补丁程序的可执行文件, 由于为现 有技术, 故这里不再赘述。 需要说明的是, 这里生成的可执行文件即所有函 数入口位置前已预留中间区的待打补丁程序。
390 其中, 如图 11所示, S2022中在函数入口位置前预留中间区的过程具体 包括:
S2022a、 设置中间区的大小和待插入的初始指令; 这里中间区的大小, 以指定字节数来表示。
如图 12a、 12b所示, 本发明一种具体实施例中, 这里的初始指令具体为 395 全 0的指令 0 x 90。 指定字节数具体为 6个字节 byte, 其中图 12a为在找到 的函数入口位置前插入 6个字节数的全 0指令的操作前的示意图; 图 12b为 在找到的函数入口位置前插入 6个字节数的全 0指令的操作后的示意图。
S2022b、 在汇编文件中查找表示函数的关键字字符串, 如果找到关键字 字符串, 则表示找到函数入口位置, 转到 S2022c; 如果没有找到, 则转到 400 S2022d, 结束对汇编文件的操作;
如图 12所示, 本发明一种具体实施例中, 这里的表示函数的关键字字符 串为 Slfunction, 如图 12所示, 查找到两处 Sfunct ion。
S2022c、 在找到的函数入口位置前插入指定字节数的初始指令, 返回执 行 S2022b, 继续查找下一处表示函数的关键字字符串, 直到找到所有函数并 405 在每个函数入口位置前插入指定字节数的初始指令。 汇编文件中插入中间区 的效果如图 12所示, 图 12 中对比表示了在找到的函数入口位置前插入 6个 字节数的全 0指令的操作前后的示意图。 请参阅图 1 3, 为本发明实施例的一种补丁管理装置的结构示意图, 需要
410 说明的是, 本发明实施例的补丁管理装置可以理解成前述的补丁管理线程, 而本发明实施例涉及的补丁管理线程的表现形式可以是独立于各种应用程序 之外的一种补丁管理程序, 或者是待打补丁的应用程序内部的线程, 如图 1 3 所示, 本实施例的补丁管理装置包括:
地址定位单元 301, 用于在待打补丁应用程序的运行过程中, 定位与该应
415 用程序关联的补丁函数的地址和待打补丁函数的入口地址;
长跳转指令单元 302,用于基于所述补丁函数的地址和所述待打补丁函数 的入口地址, 在中间区写入用于跳转到所述补丁函数的长跳转指令, 其中所 述中间区为处于待打补丁函数入口位置前或后, 且能放置至少一条长跳转指 令的存储空间; 这里的存储空间 (中间区)例如可以是待打补丁函数入口位 420 置(亦可称为函数起始位置)前或后的 128 字节内, 具体可以是函数入口位 置前的六个字节。
短跳转指令单元 303,用于将待打补丁函数入口位置处的指令修改为跳转 到所述中间区的短跳转指令, 使得所述短跳转指令被执行后, 跳转到所述中 间区, 通过所述中间区中指令的执行跳转到所述补丁函数执行。
425 为了下文描述方便, 这里将待打补丁函数入口位置处被修改为短跳转指 令的原指令称作指令 A。
在一种实现方式下, 指令 A为待打补丁函数入口位置处的首条指令, 且 长度大于或等于两字节。 在另一种实现方式下, 指令 A为待打补丁函数入口位置处的非首条指令, 430 且长度大于或等于两字节, 相应的, 长跳转指令单元 302 具体用于基于所述 补丁函数的地址和所述待打补丁函数的入口地址, 在中间区写入处于待修改 指令(即指令 A )前的操作指令的反操作指令和用于跳转到所述补丁函数的长 跳转指令, 其中所述中间区为处于待打补丁函数入口位置前或后, 且能放置 至少一条长跳转指令的存储空间;
435 相应的, 短跳转指令单元 303具体用于将待打补丁函数入口位置处的长 度大于或等于两字节的非首条指令修改为跳转到所述中间区的短跳转指令, 使得所述短跳转指令被执行后, 跳转到所述中间区, 通过所述中间区指令的 执行跳转到所述补丁函数执行。
具体地, 本实施例中, 所有单元所涉及的具体工作过程, 可以参考上述
440 在线补丁激活方法所涉及的相关实施例揭露的相关内容, 在此不再赘述。
本发明实施例还提供一种通信系统, 所述通信系统包括至少一个处理器 核和内存, 所述处理器核上运行有操作系统, 所述操作系统之上运行有至少 一种应用程序, 所述应用程序关联有补丁管理线程和至少一个业务线程, 其 中:
445 所述内存中载入有包含至少一个待打补丁函数的应用程序和包含补丁函 数的补丁文件, 其中, 所述待打补丁函数的入口位置前或后具有能放置至少 一条长跳转指令的存储空间;
所述补丁管理线程用于在所述应用程序的运行过程中, 定位所述补丁函 数的地址和所述待打补丁函数的入口地址, 并在所述存储空间写入用于跳转 450 到所述补丁函数的长跳转指令, 以及将所述待打补丁函数入口位置处的指令 修改为用于跳转到所述存储空间的短跳转指令; 所述业务线程用于执行到待打补丁函数入口位置处的短跳转指令, 跳转 到所述存储空间, 通过所述存储空间中指令的执行跳转到所述补丁函数执行。
需要说明的是, 本发明实施例涉及的处理器包括但不限于单核处理器或 455 多核处理器; 相应的, 本发明实施例提到的处理器核包括但不限于: CPU
( Central Processing Unit , 中央处理器) 核, DSP ( digital signal processor, 数字信号处理器)核, MPU (Micro Processor Unit, 处理器) 核的情况。
综上所述, 本发明前述实施例通过在待打补丁程序的函数入口位置前或
460 后预留中间区, 并在所述预留的中间区写入跳转到所述补丁函数的长跳转指 令, 以及将待打补丁函数入口位置处的指令修改为跳转到所述中间区的短跳 转指令, 补丁激活时通过该中间区进行跳转使补丁生效, 由于修改函数入口 位置处的指令的操作是原子操作, 即修改前的指令和修改后的指令的指令长 度相同, 因而仅修改一条指令即可, 无需覆盖临界区其它指令, 从而避免了
465 现有技术中对应用软件在线补丁激活时, 因系统采用复杂指令集, 跳转指令 会覆盖函数入口的多条指令, 而导致多线程调度机制下所存在的补丁激活安 全性和可靠性隐患 (即某线程执行到临界区处时刚好发生线程切换的情况, 若此时激活在线补丁, 该线程切换回来后由于原函数的临界区已被新的跳转 指令覆盖, 程序便会发生异常; 或者, 有线程处理完信号处理函数后返回(信
470 号的返回地址在临界区内) 时, 由于临界区已被跳转指令覆盖, 导致程序出 错) , 因此, 本发明实施例方法可以保证多线程条件下, 软件在线补丁激活 的安全性和可靠性, 且不会中断业务。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流 程, 是可以通过计算机程序来指令相关的硬件来完成, 所述的程序可存储于 475 一计算机可读取存储介质中, 该程序在执行时, 可包括如上述各方法的实施 例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体( Read-Only Memory , ROM )或随机存储记忆体 ( Random Acces s Memory , RAM )等。
以上举较佳实施例, 对本发明的目的、 技术方案和优点进行了进一步详 细说明, 所应理解的是, 以上所述仅为本发明的较佳实施例而已, 并不用以 480 限制本发明, 凡在本发明的精神和原则之内, 所作的任何修改、 等同替换、 改进等, 均应包含在本发明的保护范围之内。

Claims

权 利 要 求 书
1. 一种在线补丁激活方法, 其特征在于, 包括:
定位补丁函数的地址和待打补丁函数的入口地址;
485 基于所述补丁函数的地址和所述待打补丁函数的入口地址, 在中间区写 入用于跳转到所述补丁函数的长跳转指令, 其中所述中间区为处于待打补丁 函数入口位置前或后, 且能放置至少一条长跳转指令的存储空间;
将待打补丁函数入口位置处的指令修改为跳转到所述中间区的短跳转指 令, 使得所述短跳转指令被执行后, 跳转到所述中间区, 通过所述中间区指
490 令的执行跳转到所述补丁函数执行。
2.如权利要求 1 所述的在线补丁激活方法, 其特征在于, 被修改为短跳 转指令的指令为待打补丁函数入口位置处的首条指令, 且长度大于或等于两 字节。
3.如权利要求 1 所述的在线补丁激活方法, 其特征在于, 被修改为短跳
495 转指令的指令为待打补丁函数入口位置处的非首条指令, 且长度大于或等于 两字节, 所述方法还包括: 在所述中间区写入处于所述被修改指令前的操作 指令的反操作指令。
4. 如权利要求 3所述的在线补丁激活方法, 其特征在于, 所述待打补丁 函数入口位置处的非首条指令为入栈指令 push之后的指令;
500 所述处于被修改指令前的操作指令的反操作指令为出栈指令 P0p。
5. 如权利要求 1至 4中任一项所述的在线补丁激活方法, 其特征在于, 所述方法还包括:
在待打补丁程序编译时, 在所述程序的每个函数入口位置前或后预留所 述中间区。
505 6. 如权利要求 5所述的在线补丁激活方法, 其特征在于, 所述在待打补 丁程序编译时, 在所述程序的每个函数入口位置前或后预留所述中间区的步 骤, 包括:
根据控制所述中间区的预留及所述中间区的大小的编译选项, 编译待打 补丁程序的函数生成汇编指令时, 在输出函数的汇编函数名之前, 输出所述
510 编译选项指定字节数的初始指令以预留中间区。
7. 如权利要求 5所述的在线补丁激活方法, 其特征在于, 所述在待打补 丁程序编译时, 在所述程序的每个函数入口位置前或后预留所述中间区的步 骤, 包括:
515 示函数的关键字字符串;
在找到的表示函数的关键字字符串所指示的函数入口位置的前或后, 插 入指定字节数的初始指令以预留中间区; 其中, 所述指定字节数表示所述中 间区的大小;
对插入有所述初始指令的汇编文件重新编译生成新的汇编文件, 并将新 520 的汇编文件编译生成目标文件, 由多个目标文件链接生成待打补丁程序的可 执行文件。
8. 一种通信系统,其特征在于,所述通信系统包括至少一个 CPU和内存, 所述 CPU上运行有操作系统, 所述操作系统之上运行有至少一种应用程序, 所述应用程序关联有补丁管理线程和至少一个业务线程, 其中:
525 所述内存中载入有包含至少一个待打补丁函数的应用程序和包含补丁函 数的补丁文件, 其中, 所述待打补丁函数的入口位置前或后具有能放置至少 一条长跳转指令的存储空间;
所述补丁管理线程用于在所述应用程序的运行过程中, 定位所述补丁函 数的地址和所述待打补丁函数的入口地址, 并在所述存储空间写入用于跳转 530 到所述补丁函数的长跳转指令, 以及将所述待打补丁函数入口位置处的指令 修改为用于跳转到所述存储空间的短跳转指令;
所述业务线程用于执行到待打补丁函数入口位置处的短跳转指令, 跳转 到所述存储空间, 通过所述存储空间中指令的执行跳转到所述补丁函数执行。
9. 如权利要求 8所述的通信系统, 其特征在于, 所述补丁管理线程具体
535 用于在所述应用程序的运行过程中, 定位所述补丁函数的地址和所述待打补 丁函数的入口地址, 在所述存储空间写入用于跳转到所述补丁函数的长跳转 指令, 或者, 写入处于待修改指令前的操作指令的反操作指令和用于跳转到 所述补丁函数的长跳转指令, 以及将待打补丁函数入口位置处的长度大于或 等于两字节的指令修改为用于跳转到所述存储空间的短跳转指令;
540 或者, 所述补丁管理线程具体用于在所述应用程序的运行过程中, 定位 所述补丁函数的地址和所述待打补丁函数的入口地址, 并在所述存储空间写 入出栈指令 POP和用于跳转到所述补丁函数的长跳转指令, 以及将待打补丁 函数入口位置的入栈指令 pu s h之后的指令修改为用于跳转到所述存储空间的 短跳转指令。
545 10. 如权利要求 8 所述的通信系统, 其特征在于, 所述系统还包括: 编 译器, 用于在对待打补丁程序进行编译时, 在所述待打补丁程序的每个函数 入口位置前或后预留能放置至少一条长跳转指令的存储空间。
11. 如权利要求 10所述的通信系统,其特征在于,所述编译器具体用于: 根据控制所述存储空间的预留及所述存储空间的大小的编译选项, 编译待打 550 补丁的应用程序的函数生成汇编指令时, 在输出函数的汇编函数名之前, 输 出所述编译选项指定字节数的初始指令以预留能放置至少一条长跳转指令的 存储空间。
12. 如权利要求 10所述的通信系统,其特征在于,所述编译器具体用于: 将待打补丁程序的源文件编译生成汇编文件后, 查找所述汇编文件中表示函
555 数的关键字字符串, 并在找到的表示函数的关键字字符串所指示的函数入口 位置的前或后, 插入指定字节数的初始指令以预留能放置至少一条长跳转指 令的存储空间; 对插入有所述初始指令的汇编文件重新编译生成新的汇编文 件, 并将新的汇编文件编译生成目标文件, 由多个目标文件链接生成待打补 丁程序的可执行文件; 其中, 所述指定字节数表示所述存储空间的大小。
560 1 3. 如权利要求 8 所述的通信系统, 其特征在于, 所述操作系统之上进 一步运行有编译程序, 用于在对待打补丁程序进行编译时, 在所述待打补丁 程序的每个函数入口位置前或后预留能放置至少一条长跳转指令的存储空 间。
14. 一种补丁管理装置, 其特征在于, 所述装置包括:
565 地址定位单元, 用于在待打补丁应用程序的运行过程中, 定位与该应用 程序关联的补丁函数的地址和待打补丁函数的入口地址;
长跳转指令单元, 用于基于所述补丁函数的地址和所述待打补丁函数的 入口地址, 在中间区写入用于跳转到所述补丁函数的长跳转指令, 其中所述 中间区为处于待打补丁函数入口位置前或后, 且能放置至少一条长跳转指令
570 的存储空间;
短跳转指令单元, 用于将待打补丁函数入口位置处的指令修改为跳转到 所述中间区的短跳转指令, 使得所述短跳转指令被执行后, 跳转到所述中间 区, 通过所述中间区中指令的执行跳转到所述补丁函数执行。
15. 如权利要求 14所述的装置, 其特征在于, 所述长跳转指令单元具体
575 用于基于所述补丁函数的地址和所述待打补丁函数的入口地址, 在中间区写 入处于被修改指令前的操作指令的反操作指令和用于跳转到所述补丁函数的 长跳转指令, 其中所述中间区为处于待打补丁函数入口位置前或后, 且能放 置至少一条长跳转指令的存储空间;
所述短跳转指令单元具体用于将待打补丁函数入口位置处的长度大于或
580 等于两字节的非首条指令修改为跳转到所述中间区的短跳转指令, 使得所述 短跳转指令被执行后, 跳转到所述中间区, 通过所述中间区指令的执行跳转 到所述补丁函数执行。
16. 一种通信系统, 其特征在于, 所述通信系统包括至少一个处理器核 和内存, 所述处理器核上运行有操作系统, 所述操作系统之上运行有至少一
585 种应用程序, 所述应用程序关联有补丁管理线程和至少一个业务线程, 其中: 所述内存中载入有包含至少一个待打补丁函数的应用程序和包含补丁函 数的补丁文件, 其中, 所述待打补丁函数的入口位置前或后具有能放置至少 一条长跳转指令的存储空间;
所述补丁管理线程用于在所述应用程序的运行过程中, 定位所述补丁函 590 数的地址和所述待打补丁函数的入口地址, 并在所述存储空间写入用于跳转 到所述补丁函数的长跳转指令, 以及将所述待打补丁函数入口位置处的指令 修改为用于跳转到所述存储空间的短跳转指令;
所述业务线程用于执行到待打补丁函数入口位置处的短跳转指令, 跳转 到所述存储空间, 通过所述存储空间中指令的执行跳转到所述补丁函数执行。
PCT/CN2010/078271 2010-02-11 2010-10-30 在线补丁的激活方法、装置及系统 WO2011097901A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP10845571.8A EP2434394B1 (en) 2010-02-11 2010-10-30 Method, device and system for activating on-line patch
US13/336,227 US9075692B2 (en) 2010-02-11 2011-12-23 Method, device and system for activating on-line patch

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN2010101136462A CN102156661B (zh) 2010-02-11 2010-02-11 在线补丁的激活方法、装置及系统
CN201010113646.2 2010-02-11

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US13/336,227 Continuation US9075692B2 (en) 2010-02-11 2011-12-23 Method, device and system for activating on-line patch

Publications (1)

Publication Number Publication Date
WO2011097901A1 true WO2011097901A1 (zh) 2011-08-18

Family

ID=44367208

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2010/078271 WO2011097901A1 (zh) 2010-02-11 2010-10-30 在线补丁的激活方法、装置及系统

Country Status (4)

Country Link
US (1) US9075692B2 (zh)
EP (1) EP2434394B1 (zh)
CN (1) CN102156661B (zh)
WO (1) WO2011097901A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9075692B2 (en) 2010-02-11 2015-07-07 Huawei Technologies Co., Ltd. Method, device and system for activating on-line patch

Families Citing this family (34)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8539469B2 (en) * 2004-05-11 2013-09-17 Microsoft Corporation Efficient patching
CN102609241B (zh) * 2012-01-19 2018-04-27 中兴通讯股份有限公司 热补丁方法及装置
CN103294457B (zh) * 2012-02-27 2017-02-01 百度在线网络技术(北京)有限公司 动态替换主程序中c/c++函数的方法及装置
CN103309683B (zh) * 2012-03-07 2016-08-03 京信通信系统(中国)有限公司 硬件设备的软件补丁嵌入方法及装置
CN103399774A (zh) * 2013-07-29 2013-11-20 华为技术有限公司 链接方法及链接器及计算机系统
US10310863B1 (en) 2013-07-31 2019-06-04 Red Hat, Inc. Patching functions in use on a running computer system
CN103399775A (zh) * 2013-08-05 2013-11-20 北京华为数字技术有限公司 一种热补丁方法及设备
CN104424037B (zh) * 2013-08-29 2018-12-14 中兴通讯股份有限公司 一种动态补丁函数的方法及装置
CN103530184B (zh) * 2013-10-24 2017-04-12 华为技术有限公司 一种在线补丁激活的方法及装置
CN104461625A (zh) * 2014-12-04 2015-03-25 上海斐讯数据通信技术有限公司 一种热补丁实现方法和系统
US9841971B1 (en) * 2015-03-11 2017-12-12 Intuit, Inc. Embedding software updates into content retrieved by applications
CN104765634B (zh) * 2015-05-06 2017-12-08 中孚信息股份有限公司 一种Linux系统内核新功能增加方法
CN104809018B (zh) * 2015-05-18 2018-01-02 烽火通信科技股份有限公司 一种嵌入式系统软件注入热补丁的方法及系统
CN105138341A (zh) * 2015-09-24 2015-12-09 上海斐讯数据通信技术有限公司 基于MIPS架构和vxworks系统实现热补丁长跳转的方法
CN106874022B (zh) * 2015-12-11 2021-06-25 中兴通讯股份有限公司 一种热补丁注入方法及装置
CN105607937B (zh) * 2015-12-25 2019-01-18 京信通信系统(中国)有限公司 一种热补丁方法及设备
CN106775671A (zh) * 2016-11-30 2017-05-31 武汉虹信通信技术有限责任公司 一种用于通信系统linux环境中的热补丁修复方法
CN106610857B (zh) * 2016-12-23 2019-01-22 优刻得科技股份有限公司 一种热补丁信息查询方法以及装置
CN107357622B (zh) * 2017-07-17 2020-09-22 迈普通信技术股份有限公司 热补丁实现方法及通信设备
CN107943517A (zh) * 2017-10-26 2018-04-20 北京奇虎科技有限公司 终端应用的挂钩方法及装置
CN107943544B (zh) * 2017-12-11 2021-10-08 北京奇虎科技有限公司 一种内核补丁的加载方法及装置
US10698668B1 (en) * 2018-05-29 2020-06-30 Amazon Technologies, Inc. Custom code transformations during compilation process
US10649763B2 (en) * 2018-06-15 2020-05-12 Microsoft Technology Licensing, Llc Resource efficient deployment of multiple hot patches
JP7081805B2 (ja) * 2018-06-21 2022-06-07 日本電気通信システム株式会社 情報処理装置、ロードモジュール生成方法及びプログラム、並びに、動的プログラム更新システム及び方法
CN108874438B (zh) * 2018-06-25 2021-09-21 南京中感微电子有限公司 补丁生成方法、装置、电子设备及计算机存储介质
CN110673899B (zh) * 2018-07-03 2022-06-21 武汉斗鱼网络科技有限公司 一种程序处理方法及相关设备
CN111381905B (zh) * 2018-12-27 2023-07-18 北京华为数字技术有限公司 一种程序处理方法、装置及设备
CN109766145A (zh) * 2019-01-22 2019-05-17 杭州云缔盟科技有限公司 一种Windows下通过HOOK技术实现函数热补丁的方法
CN110225048B (zh) * 2019-06-19 2022-09-23 腾讯科技(成都)有限公司 数据传输方法、装置、第一终端及存储介质
CN110888667A (zh) * 2019-10-30 2020-03-17 北京军懋国兴科技股份有限公司 一种arm芯片程序在线重构的方法
CN110928570A (zh) * 2019-11-27 2020-03-27 北京知道创宇信息技术股份有限公司 一种固件升级的方法及装置、可读存储介质
CN112988182A (zh) * 2019-12-13 2021-06-18 中兴通讯股份有限公司 Linux内核热补丁实现方法、电子设备及计算机可读介质
CN111868684A (zh) * 2020-01-17 2020-10-30 深圳市汇顶科技股份有限公司 为芯片打补丁的方法及芯片
CN115952491B (zh) * 2022-12-30 2023-09-29 北京基调网络股份有限公司 hook目标函数的方法、装置、电子设备及介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1737773A (zh) * 2004-08-16 2006-02-22 上海华为技术有限公司 对嵌入式系统进行在线监测的方法及其系统
CN101004681A (zh) * 2006-12-22 2007-07-25 中兴通讯股份有限公司 嵌入式系统动态补丁长跳转的实现方法
CN101482834A (zh) * 2009-01-20 2009-07-15 华为技术有限公司 在线补丁激活方法、通信装置及系统

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE4434895C2 (de) * 1993-12-23 1998-12-24 Hewlett Packard Co Verfahren und Vorrichtung zur Behandlung von Ausnahmebedingungen
US5619698A (en) * 1995-05-05 1997-04-08 Apple Computer, Inc. Method and apparatus for patching operating systems
US6760908B2 (en) * 2001-07-16 2004-07-06 Namodigit Corporation Embedded software update system
CN1230744C (zh) 2002-08-16 2005-12-07 华为技术有限公司 一种嵌入式系统软件补丁的实现和控制方法
US7784044B2 (en) * 2002-12-02 2010-08-24 Microsoft Corporation Patching of in-use functions on a running computer system
US7886287B1 (en) * 2003-08-27 2011-02-08 Avaya Inc. Method and apparatus for hot updating of running processes
US20060015855A1 (en) * 2004-07-13 2006-01-19 Kumamoto Danny N Systems and methods for replacing NOP instructions in a first program with instructions of a second program
US8381203B1 (en) * 2006-11-03 2013-02-19 Nvidia Corporation Insertion of multithreaded execution synchronization points in a software program
CN102156661B (zh) 2010-02-11 2013-06-12 华为技术有限公司 在线补丁的激活方法、装置及系统

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1737773A (zh) * 2004-08-16 2006-02-22 上海华为技术有限公司 对嵌入式系统进行在线监测的方法及其系统
CN101004681A (zh) * 2006-12-22 2007-07-25 中兴通讯股份有限公司 嵌入式系统动态补丁长跳转的实现方法
CN101482834A (zh) * 2009-01-20 2009-07-15 华为技术有限公司 在线补丁激活方法、通信装置及系统

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP2434394A4 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9075692B2 (en) 2010-02-11 2015-07-07 Huawei Technologies Co., Ltd. Method, device and system for activating on-line patch

Also Published As

Publication number Publication date
EP2434394A1 (en) 2012-03-28
EP2434394B1 (en) 2015-10-21
CN102156661A (zh) 2011-08-17
US9075692B2 (en) 2015-07-07
CN102156661B (zh) 2013-06-12
EP2434394A4 (en) 2012-05-02
US20120102476A1 (en) 2012-04-26

Similar Documents

Publication Publication Date Title
WO2011097901A1 (zh) 在线补丁的激活方法、装置及系统
JP4514105B2 (ja) 拡張ランタイムホスティング
US8924922B2 (en) Pre-compiling hosted managed code
US7543282B2 (en) Method and apparatus for selectively executing different executable code versions which are optimized in different ways
Makris et al. Dynamic and adaptive updates of non-quiescent subsystems in commodity operating system kernels
US8015558B1 (en) System, method and computer program product for on-the-fly patching of executable code
US7596781B2 (en) Register-based instruction optimization for facilitating efficient emulation of an instruction stream
US9378008B2 (en) Method and system for creating, applying, and removing a software fix
US20040107416A1 (en) Patching of in-use functions on a running computer system
US8762967B2 (en) Program compiler, program installer, and program install method
US20130111446A1 (en) Memory management for closures
WO2012100535A1 (zh) 超级内核组件的升级方法和计算机系统
JP2000112772A (ja) 命令セット内の命令に応答してプロセスを実行するデ―タ処理システムおよびその命令処理方法
CN103218262B (zh) 在线补丁的激活方法、装置及系统
US7480902B2 (en) Unwind information for optimized programs
JP2022545012A (ja) メモリー・アパーチャのフラッシュ・オーダーを使用したデーター保存
CN109829313B (zh) 一种基于代码复用编程防御sgx侧信道攻击的方法及装置
US10496433B2 (en) Modification of context saving functions
US8423974B2 (en) System and method for call replacement
CN113342389B (zh) 一种服务的更新方法、装置及计算机可读存储介质
JPH07152551A (ja) コンピュータシステムおよびプログラム実行方法
Maeda et al. Writing an OS kernel in a strictly and statically typed language
CN114253523A (zh) 读取裸设备的方法、装置、计算机设备和介质
Christensen Methods for handling exceptions in object-oriented programming languages
CN117076052A (zh) 模式跳转方法、装置、电子设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 10845571

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 5111/KOLNP/2011

Country of ref document: IN

Ref document number: 2010845571

Country of ref document: EP

NENP Non-entry into the national phase

Ref country code: DE