WO2017096917A1 - 一种热补丁注入方法及装置 - Google Patents

一种热补丁注入方法及装置 Download PDF

Info

Publication number
WO2017096917A1
WO2017096917A1 PCT/CN2016/091753 CN2016091753W WO2017096917A1 WO 2017096917 A1 WO2017096917 A1 WO 2017096917A1 CN 2016091753 W CN2016091753 W CN 2016091753W WO 2017096917 A1 WO2017096917 A1 WO 2017096917A1
Authority
WO
WIPO (PCT)
Prior art keywords
instruction
target
code
patch
address
Prior art date
Application number
PCT/CN2016/091753
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 中兴通讯股份有限公司
Publication of WO2017096917A1 publication Critical patent/WO2017096917A1/zh

Links

Images

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 application relates to, but is not limited to, the field of computer software, and in particular, to a hot patch injection method and apparatus.
  • Hot patching the system means that the functions to be replaced in the original software system are separately modified and recompiled into hot patch units, and then loaded into the running target software system by the hot patch loading tool to replace the original function.
  • the related art hot patching technique has two problems. One is that the code that needs to be compiled in advance in the injected process is responsible for the replacement of the patched function by the patch function; the second is when the first few instructions of the function to be replaced are When modifying to jump to a new patch function, patch loading is risky.
  • the related solutions to this risk are narrow in application, not universal, and add extra memory and CPU consumption.
  • the present application provides a hot patch injection method and apparatus, so as to implement hot patch injection without relying on pre-compiled code in the injected process, and reduce consumption during hot patch injection.
  • a hot patch injection method including:
  • the N-line instruction is modified to an instruction that jumps to the first address of the patch code.
  • the step of determining that consecutive N lines of instructions starting from the first address in the replaced code are not run by any thread includes:
  • a continuous N line instruction starting from the first address in the replaced code is used as the target instruction, and at least one instruction other than the target instruction is modified into an abnormal instruction;
  • the method further includes:
  • the step of modifying the at least one instruction other than the target instruction to the abnormal instruction comprises:
  • the step of loading the patch code into the target process includes:
  • the application further provides a computer readable storage medium storing computer executable instructions that are implemented when the computer executable instructions are executed.
  • An embodiment of the present invention further provides a hot patch injection device, including:
  • Loading unit set to load the patch code into the target process
  • the continuous N-line instruction set to determine the start of the first address in the replaced code is not run by any thread greater than or equal to the minimum number of instructions required to jump to an arbitrary address in the memory in the target architecture;
  • the modifying unit is configured to modify the N-line instruction to an instruction to jump to the first address of the patch code.
  • the determining unit is configured to:
  • a continuous N line instruction starting from the first address in the replaced code is used as the target instruction, and at least one instruction other than the target instruction is modified into an abnormal instruction;
  • the modifying unit is further configured to:
  • the at least one instruction modified to the abnormal instruction is restored to the original instruction, and all threads in the target process are continued to be executed.
  • the determining unit modifies the at least one instruction other than the target instruction to the abnormal instruction, including:
  • the loading unit is configured to:
  • the utility model has the following beneficial effects: the hot patch injection method and device provided by the embodiment of the present invention load the patch code into the target process, and when it is determined that the consecutive N lines of the first address starting from the replaced code are not run by any thread
  • the N line instruction is modified to jump to the first address of the patch code, and the code that is replaced can be jumped to the patch code during the running process, thereby implementing hot patch injection without being injected into the process.
  • Pre-compilation also reduces memory and CPU consumption during hot patch injection. Since the N-line instruction is modified to jump to the first address of the patch code, it is determined that the consecutive N-line instructions starting from the first address in the replaced code are not run by any thread, and the patch loading is also reduced. Operational risk.
  • FIG. 1 is a flowchart of a hot patch injection method according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a hot patch injection method in an example according to an embodiment of the present invention.
  • FIG. 3 is a schematic structural diagram of a hot patch injection device according to an embodiment of the present invention.
  • a hot patch injection method including:
  • Step S101 loading the patch code into the target process
  • Step S102 Determine that consecutive N lines of instructions starting from the first address in the replaced code are not run by any thread, where N is greater than or equal to the minimum number of instructions required to jump to an arbitrary address in the memory in the target architecture;
  • Step S103 modifying the N line instruction to an instruction to jump to the first address of the patch code.
  • the instruction that changes the N line instruction to jump to the first address of the patch code can be replaced by the running process.
  • the code jumps to the patch code to enable hot patch injection without prior compilation of the injected process, and also reduces memory and CPU consumption during hot patch injection. Since the N-line instruction is modified to jump to the first address of the patch code, it is determined that the consecutive N-line instructions starting from the first address in the replaced code are not run by any thread, and the patch loading is also reduced. Operational risk.
  • the method can be performed by a hot patch injection tool or a device containing a hot patch injection tool.
  • the exception catching tool may be used to determine that consecutive N lines of instructions starting from the first address in the replaced code are not run by any thread. At this time, in step S102, the continuous N line instruction that determines the first address in the replaced code does not have The steps that are run by any thread, including:
  • a continuous N line instruction starting from the first address in the replaced code is used as the target instruction, and at least one instruction other than the target instruction is modified into an abnormal instruction;
  • Threads that have all pointers in the target instruction continue to execute, and when all threads are captured by the exception capture tool, it is determined that the target instruction is not run by any thread;
  • step S103 after the step of modifying the N line instruction to the instruction of jumping to the first address of the patch code, the method further includes:
  • the next instruction of the target instruction may be modified into an abnormal instruction, and the efficiency of the abnormal capture is higher and the modification amount is less.
  • the step of modifying the at least one instruction other than the target instruction to the abnormal instruction includes:
  • the loading of the patch code may be implemented by using a tool such as a code injection.
  • the step of loading the patch code into the target process in step S101 includes:
  • Step S201 implementing code injection through a combination of a basic API (Application Programming Interface) provided by the target operating system, and loading the patch module PATCH into the process space of the PROC;
  • a basic API Application Programming Interface
  • Step S202 suspending all threads in the process PROC
  • Step S203 traversing all the threads, determining whether there is a PC (Program Counter) pointer in the thread of the first N instructions in the instruction area to be replaced, and if there is a PC pointer in the thread of the first N instructions in the command area to be replaced, Step S204 is performed, if there is no PC pointer in the thread of the first N instructions in the command area to be replaced, step S208 is performed;
  • PC Program Counter
  • Step S204 Find the first address of the function FUNC1, record the N+1th instruction starting from the first address, and then modify the instruction to an abnormal instruction, where N is equal to the minimum instruction required to jump to an arbitrary address in the memory in the target architecture. number;
  • Step S205 Let all the PC pointers in the instruction to replace the first N instructions continue to execute;
  • Step S206 determining that the thread that continues to be executed is captured by the exception capture tool
  • Step S207 restoring the N+1th instruction of FUNC1 to the original normal instruction
  • Step S208 modifying the first N instructions of FUNC1 to an instruction that jumps to the first address of the patch function FUNC2;
  • step S209 all the threads in the process PROC are restored to normal operation, and thus the replacement of any instruction is completed safely.
  • the above steps may be performed by a hot patch injection tool or a device including a hot patch injection tool.
  • Embodiments of the present invention further provide a computer readable storage medium storing computer executable instructions that are implemented when the computer executable instructions are executed.
  • a hot patch injection device is further provided, and the device may be a hot patch injection tool or a device including a hot patch injection tool. As shown in FIG. 3, the device includes:
  • the loading unit 301 is configured to load the patch code into the target process
  • the determining unit 302 is configured to determine that the consecutive N lines of instructions starting from the first address in the replaced code are not run by any thread, and N is greater than or equal to the minimum number of instructions required to jump to an arbitrary address in the memory in the target architecture;
  • the modifying unit 303 is configured to modify the N line instruction to an instruction to jump to the first address of the patch code.
  • the determining unit 302 is configured to:
  • Threads that have all pointers in the target instruction continue to execute, and when all threads are captured by the exception capture tool, it is determined that the target instruction is not run by any thread;
  • the modification unit 303 is further configured to:
  • the determining unit 302 modifies the at least one instruction other than the target instruction to the abnormal instruction, including:
  • the loading unit 301 is configured to:
  • the hot patch injection method and apparatus load the patch code into the target process, and when the continuous N line instruction starting from the first address in the replaced code is determined not to be run by any thread, the N line instruction is The instruction modified to jump to the first address of the patch code can be implemented by the replaced code to jump to the patch code during the running process, thereby implementing hot patch injection, which does not need to be compiled in the process to be injected, and is also reduced.
  • the consumption of the hot patch injection is small. Since the N-line instruction is modified to jump to the first address of the patch code, it is determined that the consecutive N-line instructions starting from the first address in the replaced code are not run by any thread, and the patch loading is also reduced. Operational risk.
  • each module/unit in the above embodiment may be implemented in the form of hardware, for example, by implementing an integrated circuit to implement its corresponding function, or may be implemented in the form of a software function module, for example, executing a program stored in the memory by a processor. / instruction to achieve its corresponding function.
  • Embodiments of the invention are not limited to any specific form of combination of hardware and software.
  • the hot patch injection method and apparatus load the patch code into the target process, and when the continuous N line instruction starting from the first address in the replaced code is determined not to be run by any thread, the N line instruction is The instruction modified to jump to the first address of the patch code can be implemented by the replaced code to jump to the patch code during the running process, thereby implementing hot patch injection, which does not need to be compiled in the process to be injected, and is also reduced. Small memory and CPU consumption when hot patch injection. Since the N-line instruction is modified to jump to the first address of the patch code, it is determined that the consecutive N-line instructions starting from the first address in the replaced code are not run by any thread, and the patch loading is also reduced. Operational risk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

公开了一种热补丁注入方法及装置,涉及计算机软件领域,该方法包括:将补丁代码加载到目标进程中,在确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行时,将该N行指令修改为跳转到补丁代码的首地址的指令,在运行过程中即可实现由被替换的代码跳转到补丁代码,从而实现热补丁注入,不需要被注入的进程中有事先编译,也减小了热补丁注入时的消耗。由于在将该N行指令修改为跳转到补丁代码的首地址的指令前,确定了被替换的代码中首地址开始的连续N行指令没有被任何线程运行,也减小了补丁加载时的运行风险。

Description

一种热补丁注入方法及装置 技术领域
本申请涉及但不限于计算机软件领域,特别是一种热补丁注入方法及装置。
背景技术
对于正在运行的软件系统,想要进行一些功能扩展或者修补一些软件问题,而又要求不能复位系统,这就需要给系统打热补丁。
给系统打热补丁就是把原来软件系统中的想要替换的函数单独修改重新编译组成热补丁单元,再通过热补丁加载工具加载到运行的目标软件系统中,替换原始函数。
然而,相关技术的热补丁技术有两个问题,一是需要在被注入的进程中有事先编译进去的代码负责补丁函数对被补函数的替换;二是当将被替换函数的头几条指令修改为跳转到新的补丁函数时,补丁加载存在风险,解决这个风险的相关方案都存在应用面窄,不通用,增加额外的内存与CPU的消耗的问题。
发明内容
以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。
本申请提供一种热补丁注入方法及装置,以实现不依赖被注入的进程中有事先编译进去的代码进行热补丁注入,并减小热补丁注入时的消耗。
依据本申请的一个方面,提供一种热补丁注入方法,包括:
将补丁代码加载到目标进程中;
确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行,其中,所述N大于或等于目标体系结构中跳转到内存任意地址所需要的最小指令数;
将所述N行指令修改为跳转到补丁代码的首地址的指令。
可选地,所述确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行的步骤,包括:
暂停目标进程内的所有线程;
把从被替换的代码中首地址开始的连续N行指令作为目标指令,并将该目标指令之外的至少一条指令修改为异常指令;
让所有指针处于目标指令中的线程继续执行,当所有线程均被异常捕获工具捕捉时,确定所述目标指令没有被任何线程运行;
此时,所述将所述N行指令修改为跳转到补丁代码的首地址的指令的步骤后,所述方法还包括:
将所述修改为异常指令的至少一条指令恢复为原指令;
继续执行目标进程内的所有线程。
可选地,所述将该目标指令之外的至少一条指令修改为异常指令的步骤,包括:
将该目标指令的后一条指令修改为异常指令。
可选地,所述将补丁代码加载到目标进程中的步骤,包括:
通过代码注入将补丁代码加载到目标进程中。
本申请另外提供一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令被执行时实现上述方法。
本发明实施例还相应提供一种热补丁注入装置,包括:
加载单元,设置成将补丁代码加载到目标进程中;
确定单元,设置成确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行,所述N大于或等于目标体系结构中跳转到内存任意地址所需要的最小指令数;
修改单元,设置成将所述N行指令修改为跳转到补丁代码的首地址的指令。
可选地,所述确定单元是设置成:
暂停目标进程内的所有线程;
把从被替换的代码中首地址开始的连续N行指令作为目标指令,并将该目标指令之外的至少一条指令修改为异常指令;
让所有指针处于目标指令中的线程继续执行,当所有线程均被异常捕获工具捕捉时,确定所述目标指令没有被任何线程运行;
此时,所述修改单元还设置成:
将所述N行指令修改为跳转到补丁代码的首地址的指令后,将所述修改为异常指令的至少一条指令恢复为原指令,并继续执行目标进程内的所有线程。
可选地,所述确定单元将该目标指令之外的至少一条指令修改为异常指令,包括:
将该目标指令的后一条指令修改为异常指令。
可选地,所述加载单元是设置成:
通过代码注入将补丁代码加载到目标进程中。
本申请有益效果如下:通过本发明实施例提供的热补丁注入方法及装置,将补丁代码加载到目标进程中,在确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行时,将该N行指令修改为跳转到补丁代码的首地址的指令,在运行过程中即可实现由被替换的代码跳转到补丁代码,从而实现热补丁注入,不需要被注入的进程中有事先编译,也减小了热补丁注入时内存和CPU的消耗。由于在将该N行指令修改为跳转到补丁代码的首地址的指令前,确定了被替换的代码中首地址开始的连续N行指令没有被任何线程运行,也减小了补丁加载时的运行风险。
在阅读并理解了附图和详细描述后,可以明白其他方面。
附图概述
为了更清楚地说明本发明实施例或相关技术中的技术方案,下面将对实施例或相关技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲, 在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的热补丁注入方法的流程图;
图2为本发明实施例提供的实例中的热补丁注入方法的流程图;
图3为本发明实施例提供的热补丁注入装置的结构示意图。
本发明的较佳实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
如图1所示,在本发明的一个实施例中,提供的热补丁注入方法,包括:
步骤S101、将补丁代码加载到目标进程中;
步骤S102、确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行,其中,N大于或等于目标体系结构中跳转到内存任意地址所需要的最小指令数;
步骤S103、将N行指令修改为跳转到补丁代码的首地址的指令。
在确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行时,将该N行指令修改为跳转到补丁代码的首地址的指令,在运行过程中即可实现由被替换的代码跳转到补丁代码,从而实现热补丁注入,而不需要被注入的进程中有事先编译,也减小了热补丁注入时的内存和CPU的消耗。由于在将该N行指令修改为跳转到补丁代码的首地址的指令前,确定了被替换的代码中首地址开始的连续N行指令没有被任何线程运行,也减小了补丁加载时的运行风险。
该方法可以由热补丁注入工具或者包含热补丁注入工具的装置来执行。
可以利用异常捕获工具来确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行,此时,步骤S102中,所述确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行的步骤,包括:
暂停目标进程内的所有线程;
把从被替换的代码中首地址开始的连续N行指令作为目标指令,并将该目标指令之外的至少一条指令修改为异常指令;
让所有指针处于目标指令中的线程继续执行,当所有线程均被异常捕获工具捕捉时,确定目标指令没有被任何线程运行;
此时,步骤S103中,所述将N行指令修改为跳转到补丁代码的首地址的指令的步骤后,所述方法还包括:
将修改为异常指令的至少一条指令恢复为原指令;
继续执行目标进程内的所有线程。
当然,本领域技术人员也可以采用其它的方法或利用其它工具来确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行,此处不再一一说明。
可选地,为提高异常捕获的效率,可以将该目标指令的后一条指令修改为异常指令,此时异常捕获的效率较高,修改量较少。此时,所述将该目标指令之外的至少一条指令修改为异常指令的步骤,包括:
将该目标指令的后一条指令修改为异常指令。
可选地,可以通过代码注入等工具来实现补丁代码的加载,此时,步骤S101中,所述将补丁代码加载到目标进程中的步骤,包括:
通过代码注入将补丁代码加载到目标进程中。
下面,通过一个实例对本发明实施例提供的热补丁注入方法进行说明:
下面假设目的进程PROC中存在函数FUNC1,热补丁PATCH模块中存在函数FUNC2,目标体系结构中跳转到内存任意地址需要N条指令,欲将FUNC1替换为补丁函数FUNC2,如图2所示,详细实施步骤如下:
步骤S201、通过目标操作系统提供的基础API(Application Programming Interface,应用程序编程接口)组合实现代码注入,把补丁模块PATCH加载到PROC的进程空间;
步骤S202、暂停进程PROC内的所有线程;
步骤S203、遍历所有线程,确定是否有PC(Program Counter,程序计数器)指针处于欲替换指令区域中前N条指令的线程,如果有PC指针处于欲替换指令区域中前N条指令的线程,则执行步骤S204,若没有PC指针处于欲替换指令区域中前N条指令的线程,则执行步骤S208;
步骤S204、找到函数FUNC1的首地址,将首地址开始的第N+1条指令先记录下来,再修改为异常指令,其中,N等于目标体系结构中跳转到内存任意地址所需要的最小指令数;
步骤S205、让所有PC指针处于欲替换指令区域中前N条指令的线程继续执行;
步骤S206、确定继续执行的线程都被异常捕获工具捕捉到;
步骤S207、把FUNC1的第N+1条指令恢复为原始的正常指令;
步骤S208、将FUNC1的前N条指令修改为跳转到补丁函数FUNC2首地址的指令;
正在执行函数FUNC1前N条指令的线程执行到FUNC1的第N+1条指令时,会触发刚才放置的异常指令从而产生异常,当所有这样的线程都被异常捕获工具捕捉到时,此时进程PROC内已经没有任何线程在运行FUNC1的前N条指令了,因此可以安全的去修改FUNC1的前N条指令了,此时即可将这N条指令修改为跳转到补丁函数FUNC2首地址的指令,并把FUNC1的第N+1条指令恢复为原始的正常指令;
步骤S209、让进程PROC内的所有线程恢复正常运行,至此安全的完成了任意条指令的替换。
上述步骤可以由热补丁注入工具或者包含热补丁注入工具的装置来执行。
本发明实施例另外提供一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令被执行时实现上述方法。
在本发明的另一个实施例中,还相应提供一种热补丁注入装置,该装置可以为热补丁注入工具,也可以为包含热补丁注入工具的装置,如图3所示,该装置包括:
加载单元301,设置成将补丁代码加载到目标进程中;
确定单元302,设置成确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行,N大于或等于目标体系结构中跳转到内存任意地址所需要的最小指令数;
修改单元303,设置成将N行指令修改为跳转到补丁代码的首地址的指令。
可选地,确定单元302设置成:
暂停目标进程内的所有线程;
确定被替换的代码中首地址开始的连续N行指令为目标指令,并将该目标指令之外的至少一条指令修改为异常指令;
让所有指针处于目标指令中的线程继续执行,当所有线程均被异常捕获工具捕捉时,确定目标指令没有被任何线程运行;
此时,修改单元303还设置成:
将N行指令修改为跳转到补丁代码的首地址的指令后,将修改为异常指令的至少一条指令恢复为原指令,并继续执行目标进程内的所有线程。
可选地,为提高热补丁注入的效率,确定单元302将该目标指令之外的至少一条指令修改为异常指令,包括:
将该目标指令的后一条指令修改为异常指令。
可选地,加载单元301设置成:
通过代码注入将补丁代码加载到目标进程中。
通过本发明实施例提供的热补丁注入方法及装置,将补丁代码加载到目标进程中,在确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行时,将该N行指令修改为跳转到补丁代码的首地址的指令,在运行过程中即可实现由被替换的代码跳转到补丁代码,从而实现热补丁注入,不需要被注入的进程中有事先编译,也减小了热补丁注入时的消耗。由于在将该N行指令修改为跳转到补丁代码的首地址的指令前,确定了被替换的代码中首地址开始的连续N行指令没有被任何线程运行,也减小了补丁加载时的运行风险。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是其与其他实施例的不同之处。尤其对于装置实施例而言,由于其基本相似与方法实施例,所以,描述的比较简单,相关之处参见方法实施例的部分说明即可。
本领域普通技术人员可以理解上述方法中的全部或部分步骤可通过程序来指令相关硬件(例如处理器)完成,所述程序可以存储于计算机可读存储介质中,如只读存储器、磁盘或光盘等。可选地,上述实施例的全部或部分步骤也可以使用一个或多个集成电路来实现。相应地,上述实施例中的各模块/单元可以采用硬件的形式实现,例如通过集成电路来实现其相应功能,也可以采用软件功能模块的形式实现,例如通过处理器执行存储于存储器中的程序/指令来实现其相应功能。本发明实施例不限制于任何特定形式的硬件和软件的结合。
虽然通过实施例描述了本申请,本领域的技术人员知道,本申请有许多变形和变化而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。
工业实用性
通过本发明实施例提供的热补丁注入方法及装置,将补丁代码加载到目标进程中,在确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行时,将该N行指令修改为跳转到补丁代码的首地址的指令,在运行过程中即可实现由被替换的代码跳转到补丁代码,从而实现热补丁注入,不需要被注入的进程中有事先编译,也减小了热补丁注入时内存和CPU的消耗。由于在将该N行指令修改为跳转到补丁代码的首地址的指令前,确定了被替换的代码中首地址开始的连续N行指令没有被任何线程运行,也减小了补丁加载时的运行风险。

Claims (8)

  1. 一种热补丁注入方法,包括:
    将补丁代码加载到目标进程中;
    确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行,其中,所述N大于或等于目标体系结构中跳转到内存任意地址所需要的最小指令数;
    将所述N行指令修改为跳转到补丁代码的首地址的指令。
  2. 如权利要求1所述的方法,其中,所述确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行的步骤,包括:
    暂停目标进程内的所有线程;
    把从被替换的代码中首地址开始的连续N行指令作为目标指令,并将该目标指令之外的至少一条指令修改为异常指令;
    让所有指针处于目标指令中的线程继续执行,当所有线程均被异常捕获工具捕捉时,确定所述目标指令没有被任何线程运行;
    所述将所述N行指令修改为跳转到补丁代码的首地址的指令的步骤后,所述方法还包括:
    将所述修改为异常指令的至少一条指令恢复为原指令;
    继续执行目标进程内的所有线程。
  3. 如权利要求2所述的方法,其中,所述将该目标指令之外的至少一条指令修改为异常指令的步骤,包括:
    将该目标指令的后一条指令修改为异常指令。
  4. 如权利要求1所述的方法,其中,所述将补丁代码加载到目标进程中的步骤,包括:
    通过代码注入将补丁代码加载到目标进程中。
  5. 一种热补丁注入装置,包括:
    加载单元,设置成将补丁代码加载到目标进程中;
    确定单元,设置成确定被替换的代码中首地址开始的连续N行指令没有被任何线程运行,所述N大于或等于目标体系结构中跳转到内存任意地址所需要的最小指令数;
    修改单元,设置成将所述N行指令修改为跳转到补丁代码的首地址的指令。
  6. 如权利要求5所述的装置,其中,所述确定单元是设置成:
    暂停目标进程内的所有线程;
    把从被替换的代码中首地址开始的连续N行指令作为目标指令,并将该目标指令之外的至少一条指令修改为异常指令;
    让所有指针处于目标指令中的线程继续执行,当所有线程均被异常捕获工具捕捉时,确定所述目标指令没有被任何线程运行;
    所述修改单元还设置成:
    将所述N行指令修改为跳转到补丁代码的首地址的指令后,将所述修改为异常指令的至少一条指令恢复为原指令,并继续执行目标进程内的所有线程。
  7. 如权利要求6所述的装置,其中,所述确定单元将该目标指令之外的至少一条指令修改为异常指令,包括:将该目标指令的后一条指令修改为异常指令。
  8. 如权利要求5所述的装置,其中,所述加载单元是设置成:
    通过代码注入将补丁代码加载到目标进程中。
PCT/CN2016/091753 2015-12-11 2016-07-26 一种热补丁注入方法及装置 WO2017096917A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510924194.9A CN106874022B (zh) 2015-12-11 2015-12-11 一种热补丁注入方法及装置
CN201510924194.9 2015-12-11

Publications (1)

Publication Number Publication Date
WO2017096917A1 true WO2017096917A1 (zh) 2017-06-15

Family

ID=59013711

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/091753 WO2017096917A1 (zh) 2015-12-11 2016-07-26 一种热补丁注入方法及装置

Country Status (2)

Country Link
CN (1) CN106874022B (zh)
WO (1) WO2017096917A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112559085A (zh) * 2020-12-23 2021-03-26 苏州三六零智能安全科技有限公司 物联网设备的插件加载方法、设备、存储介质及装置
CN112631639A (zh) * 2020-12-23 2021-04-09 苏州三六零智能安全科技有限公司 补丁代码添加方法、装置、设备及计算机可读存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107357622B (zh) * 2017-07-17 2020-09-22 迈普通信技术股份有限公司 热补丁实现方法及通信设备
CN110618824B (zh) * 2018-06-20 2023-07-21 中移(杭州)信息技术有限公司 一种软件升级方法、装置、介质和设备
CN110308920B (zh) * 2019-05-31 2023-05-12 北京控制工程研究所 一种不影响正常运行的在轨修改星上产品软件的方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156661A (zh) * 2010-02-11 2011-08-17 华为技术有限公司 在线补丁的激活方法、装置及系统
CN102609241A (zh) * 2012-01-19 2012-07-25 中兴通讯股份有限公司 热补丁方法及装置
CN103530184A (zh) * 2013-10-24 2014-01-22 华为技术有限公司 一种在线补丁激活的方法及装置

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6310239A (ja) * 1986-06-30 1988-01-16 Nec Corp 高級言語のパツチ生成方式
CN101799763B (zh) * 2009-02-10 2013-01-30 华为技术有限公司 内核在线补丁的方法、装置和系统
CN101561764B (zh) * 2009-05-18 2012-05-23 华为技术有限公司 一种多核环境下的补丁方法与补丁装置
CN103218262B (zh) * 2010-02-11 2017-03-15 华为技术有限公司 在线补丁的激活方法、装置及系统
CN102831054B (zh) * 2012-06-30 2015-12-02 华为技术有限公司 程序断点处理方法及装置
US20150007156A1 (en) * 2013-06-26 2015-01-01 Sap Ag Injecting patch code at runtime
CN103345412B (zh) * 2013-07-10 2016-08-24 华为技术有限公司 打补丁的方法及装置
CN104424037B (zh) * 2013-08-29 2018-12-14 中兴通讯股份有限公司 一种动态补丁函数的方法及装置
US9164754B1 (en) * 2013-12-18 2015-10-20 Amazon Technologies, Inc. Runtime patching of native-code programs
US9772928B2 (en) * 2014-01-02 2017-09-26 Hewlett Packard Enterprise Development Lp Distributed kernel thread list processing for kernel patching

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156661A (zh) * 2010-02-11 2011-08-17 华为技术有限公司 在线补丁的激活方法、装置及系统
CN102609241A (zh) * 2012-01-19 2012-07-25 中兴通讯股份有限公司 热补丁方法及装置
CN103530184A (zh) * 2013-10-24 2014-01-22 华为技术有限公司 一种在线补丁激活的方法及装置

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112559085A (zh) * 2020-12-23 2021-03-26 苏州三六零智能安全科技有限公司 物联网设备的插件加载方法、设备、存储介质及装置
CN112631639A (zh) * 2020-12-23 2021-04-09 苏州三六零智能安全科技有限公司 补丁代码添加方法、装置、设备及计算机可读存储介质
CN112559085B (zh) * 2020-12-23 2022-11-04 苏州三六零智能安全科技有限公司 物联网设备的插件加载方法、设备、存储介质及装置
CN112631639B (zh) * 2020-12-23 2022-11-04 苏州三六零智能安全科技有限公司 补丁代码添加方法、装置、设备及计算机可读存储介质

Also Published As

Publication number Publication date
CN106874022A (zh) 2017-06-20
CN106874022B (zh) 2021-06-25

Similar Documents

Publication Publication Date Title
WO2017096917A1 (zh) 一种热补丁注入方法及装置
KR101782313B1 (ko) 예외 이벤트 처리 장치 및 방법
US8499289B2 (en) Method, device and system for realizing kernel online patching
US8745596B2 (en) Program debugging with dynamically inserted instrumentation
TWI612439B (zh) 用以偵測未經授權之記憶體存取的計算裝置、方法及機器可讀儲存媒體
JP5093259B2 (ja) Biosとbmcとの間の通信パス強化方法、その装置及びそのプログラム
RU2014143109A (ru) Обработка транзакций
KR20110106716A (ko) 프로그램 컴파일러, 설치 장치, 및 설치 방법
GB2500080A (en) Prefetch optimizer tool for controlling hardware and software prefetching
JP2011086298A (ja) プログラム・フロー制御
US8225289B2 (en) Method and system for improved tool interaction with a target
CN101625659A (zh) 嵌入式系统实时监控内存的方法
KR20080057688A (ko) 비휘발성 메모리를 이용한 운영체계 부팅 방법
KR20180126518A (ko) 벡터 명령 처리
KR101341328B1 (ko) 사용자 정의 api 함수 생성 모듈 및 방법
JP2004240953A (ja) コンピュータシステム、その同時多重スレッディング方法およびキャッシュコントローラシステム。
KR101785540B1 (ko) 비결정적인 하드웨어 인터럽트에 대한 요청을 처리하는 에뮬레이션 방법 및 장치
JP7444610B2 (ja) コンテキスト・データ管理
TWI739284B (zh) 控制台程式的控制管理方法及系統
US9542188B2 (en) Hardware debugging apparatus and method for software pipelined program
US9928045B2 (en) Information processing apparatus, compile method and non-transitory recording medium storing compile program
JP2009251681A (ja) スタック領域の拡張方法及びプログラム
JP2017224012A (ja) 情報処理装置、ダイナミックリンクプログラムおよびプログラム再開方法
JP2015115052A (ja) マイクロプロセッサ、コンピュータ、異常対応方法、及び異常対策プログラム
JP5782389B2 (ja) エミュレーションシステム、エミュレーションシステムの制御方法、エミュレーション装置、プログラム

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: 16872116

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16872116

Country of ref document: EP

Kind code of ref document: A1