CN105528231B - A kind of software dynamic update method and system based on intermediate auxiliary function - Google Patents
A kind of software dynamic update method and system based on intermediate auxiliary function Download PDFInfo
- Publication number
- CN105528231B CN105528231B CN201610039757.0A CN201610039757A CN105528231B CN 105528231 B CN105528231 B CN 105528231B CN 201610039757 A CN201610039757 A CN 201610039757A CN 105528231 B CN105528231 B CN 105528231B
- Authority
- CN
- China
- Prior art keywords
- function
- updated
- update
- intermediate auxiliary
- source file
- Prior art date
- Legal status (The legal status 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 status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/50—Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
- G06F21/55—Detecting local intrusion or implementing counter-measures
- G06F21/56—Computer malware detection or handling, e.g. anti-virus arrangements
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
- G06F8/656—Updates while running
Abstract
The invention discloses a kind of software dynamic update methods based on intermediate auxiliary function to generate intermediate auxiliary function by the function to be updated in the new/old edition code source file after analytical integration;Using intermediate auxiliary function and binary rewrite mechanism, respectively in function call stack function to be updated, be not in the function to be updated of function call stack and static variable to be updated is updated.Correspondingly, the invention also provides corresponding systems.The present invention efficiently solves the multiple checkpoint bring system losses of insertion and Deadlock, while ensuring to update upgrading safety, dynamic real-time update can be carried out to program, significantly reduce the Operating Complexity and overhead of user, simultaneously, rollback can be completed when updating and occurring any abnormal, guarantee the reliability of renewal process.The present invention is applicable to the application service of highly reliable continuous drive, can reduce because version updating leads to loss caused by system reboot.
Description
Technical field
The invention belongs to the security fields in cloud software reliability research, more particularly, to one kind based on intermediate auxiliary
The software dynamic update method and system of function.
Background technique
Software needs constantly to upgrade in use more newly arrive patching bugs and addition function, however traditional software
Update needs first to close software, restarts software after the completion of updating again.One side software service understands delay machine for a period of time in this way,
Another aspect software service will be lost the state before updating.This is for needing software service in 7/24 hour, undoubtedly
Reduce the availability of service.But if not using update, safety and the service reliability of software can be undoubtedly reduced.
For this problem, the update that software dynamic update method can complete program in the case where program does not stop service upgrades work
Make, and can guarantee that software upgrading front and back service state is not lost, to improve the availability and reliability of system.
In existing dynamic software upgrade method, for the update for calling function, general there are two types of methods, a kind of
It is to be updated again after waiting function to be updated to return.Another method be the method that is reconstructed based on security update point and storehouse come
It completes to update, i.e., when waiting thread goes to some security update point in function, storehouse reconstruct is carried out to the function stack of thread
Work, makes the function stack of legacy version function be converted into the function stack of new version function, while thread being made to jump to security update point
Corresponding new version function position is updated work.
However, all there is certain deficiency and limitation in above two method.(1) after waiting function to be updated to return again into
The method that row updates can not update some functions that will not be returned, such as primitive recursive function, scheduling function etc., these function meetings
Place enters in function stack always, if cannot update can also have security risk always;(2) it is reconstructed based on checkpoint and storehouse
Although method can in function call renewal function, in multithread programs, be difficult to make all threads all to reach safety
Update point.Some methods are that all threads of program is made to can reach security checkpoints by compiler at present.However, this method
It can only be directed to the program that specific compiler compiles out, upgrading update cannot be carried out to the general procedure that universal compiler compiles out
Work.In addition there are certain methods to take obstruction thread, updated again after so that thread is all reached checkpoint, but this method may be led
Deadlock is caused, although can update by force at deadlock, unsafe update position is likely to be at by the thread that deadlock blocks
It sets, at this time if updating the safety and correctness that will affect program by force.And storehouse reconstruct method for it is certain update it is past
Toward only seldom change.The security update point of some dynamic updating methods may be only available for the program of single thread, and multithreading
Program can not reach security update point simultaneously, update so that dynamic can not be carried out to multithread programs.
Reconstructed using storehouse update call very deep function (such as in recursive function) expense of level be it is very big, can energy content
Number stack only has several functions on upper layer to have change to need to update, but storehouse reconstruct needs to reconfigure all storehouses, and heap
Program must operation suspension when stack reconstructs.Per thread has oneself independent stack in multithread programs, if using storehouse weight
The method of structure, not only renewal time can be elongated, and more seriously program can suspend the long period in renewal process.
In conclusion the scheme of existing dynamic software upgrade system has the disadvantage that
Some dynamic software upgrade methods (polus) can only update the function being not in function call stack, can not be to just
Real-time update is carried out in the function of execution, if some functions that can not be returned in a short time, such as primitive recursive function and scheduling
Function will be unable to update to next version.Some dynamic update methods (upstare) need specific compiler to support, so
Dynamic update can not be carried out to the program for using universal compiler to compile.Some dynamic software upgrade methods (Kitsune) with into
Journey is updating unit, needs to store whole code datas of new version at no point in the update process and causes overhead larger, and real
Border, which updates, often only has seldom change.The security update point of some dynamic updating methods may be only available for the program of single thread,
And multithread programs can not reach security update point simultaneously, update so that dynamic can not be carried out to multithread programs.
Summary of the invention
In view of the drawbacks of the prior art or Improvement requirement, it is dynamic that the present invention provides a kind of softwares based on intermediate auxiliary function
State upgrade method and system, it is intended that solving existing for deployed multithread application progress dynamic update
The above-mentioned limitation and deficiency occurred in method, ensure that multithread application dynamic update safety, real-time and effectively
Property.
To achieve the above object, according to one aspect of the present invention, a kind of software based on intermediate auxiliary function is proposed
Dynamic update method, which is characterized in that the described method includes:
(1) it obtains and integrates legacy version code source file and new version of code source file, the legacy version generation after being integrated
Code source file and new version of code source file;
(2) it by the legacy version code source file and new version of code source file after comparison integration, generates primary dynamic and rises
Grade patch;
(3) letter to be updated in the legacy version code source file and new version of code source file after static analysis comparison integration
Number, analyzes the semanteme of function to be updated, generating function Semantic mapping table, while according to function to be updated, generates and intermediate assists letter
Number;
(4) according to the initialization requests of user, the primary dynamic update patch generated in step (2) is injected into and is being transported
In capable program to be updated;
(5) it after injecting dynamic update patch, is obtained according to functional symbol name to be updated and static variable symbolic name to be updated
Corresponding function to be updated and static variable address to be updated in program to be updated;
(6) it is requested according to the update that user issues, suspends all processes relevant to update, and according to the to be updated of acquisition
Static variable address is updated static variable to be updated;Meanwhile checking whether function to be updated is located at function call stack, if
It is then to be updated using intermediate auxiliary function to the function to be updated for being located at function call stack;Otherwise directly to not in function
The function to be updated of call stack is updated;
(7) restore the process being suspended by update, renewal process terminates.
As it is further preferred that the step (3) specifically includes:
(3-1) analyzes the semanteme of function to be updated, obtains and record the security update instruction set of function to be updated, generates
Function Semantic mapping table;
(3-2) using the parameter of function to be updated as the parameter of intermediate auxiliary function, construction generates intermediate auxiliary function, institute
Stating intermediate auxiliary function includes control content, function new version content to be updated and function legacy version content to be updated;Wherein,
The control content is used for the part by the local variable of function legacy version to be updated and Parameter Switch at new version
Variable and parameter are also used to execute address according to thread when operation to judge whether the thread is in security update instruction set,
If so, jumping into function new version content to be updated, returned after executing function new version content to be updated;Otherwise, jump into
Function legacy version content to be updated is then jumped when going to any one instruction in security update instruction set into letter to be updated
Number new version content;
(3-3) modifies to the function legacy version content to be updated of the intermediate auxiliary function, makes it using conversion letter
Number access new edition notebook data.
As it is further preferred that if one section instruction in any one instruction before all execution routes can guarantee it is new and old
Version semantic congruence, then section instruction is security update instruction set.
As it is further preferred that the step (6) specifically includes:
(6-1) is requested according to the update that user issues, and suspends all processes relevant to update, all legacy versions are waited for
It updates static variable and is converted into new version static variable;
(6-2) checks whether function to be updated is located at function call stack, if so, according to the function Semantic mapping of step (3)
Table, next binary instruction after modifying the current execution position of thread then branch to the current execution position stacking of thread
The entry address that intermediate auxiliary function is generated in step (3), is updated using intermediate auxiliary function;Otherwise, for being not in
The function to be updated of function call stack, is updated using the method for Modification growth function entry address.
As it is further preferred that the method also includes:
(1) checkpoint of program to be updated is saved before program updates;
(2) at no point in the update process, program state to be updated is monitored in real time by monitoring programme, if program to be updated generation is different
Chang Shi carries out rollback using the checkpoint, is reverted to the state before updating.
Other side according to the invention proposes a kind of software dynamic update system based on intermediate auxiliary function,
It is characterized in that, the system comprises:
Module is integrated, for obtaining and integrating legacy version code source file and new version of code source file, after obtaining integration
Legacy version code source file and new version of code source file;
Patch generation module, for passing through legacy version code source file and new version of code source file after comparison is integrated,
Generate primary dynamic update patch;
Analysis module, in the legacy version code source file and new version of code source file after static analysis comparison integration
Function to be updated, analyze the semanteme of function to be updated, generating function Semantic mapping table, while for according to function to be updated,
Generate intermediate auxiliary function;
The primary dynamic update patch of generation is injected by injection module for the initialization requests according to user
In the program to be updated of operation;
Module is obtained, for becoming after injecting dynamic update patch according to functional symbol name to be updated and static state to be updated
Quantity symbol name obtains corresponding function to be updated and static variable address to be updated in program to be updated;
Update module, the update request for being issued according to user suspend all processes relevant to update, and according to obtaining
The static variable address to be updated taken is updated static variable to be updated;Meanwhile checking whether function to be updated is located at letter
Number call stack, if so, being updated using intermediate auxiliary function to the function to be updated for being located at function call stack;Otherwise directly
Function to be updated not in function call stack is updated;
Recovery module, the process for restoring to be suspended by update, renewal process terminate.
As it is further preferred that the analysis module specifically includes:
First analysis generation unit obtains and records the safety of function to be updated for analyzing the semanteme of function to be updated
Update instruction set, generating function Semantic mapping table;
Second analysis generation unit, for using the parameter of function to be updated as the parameter of intermediate auxiliary function, construction life
At intermediate auxiliary function, the intermediate auxiliary function includes control content, function new version content to be updated and function to be updated
Legacy version content;Wherein,
The control content is used for the part by the local variable of function legacy version to be updated and Parameter Switch at new version
Variable and parameter are also used to execute address according to thread when operation to judge whether the thread is in security update instruction set,
If so, jumping into function new version content to be updated, returned after executing function new version content to be updated;Otherwise, jump into
Function legacy version content to be updated is then jumped when going to any one instruction in security update instruction set into letter to be updated
Number new version content;
Unit is modified, is modified for the function legacy version content to be updated to the intermediate auxiliary function, its benefit is made
New edition notebook data is accessed with transfer function.
As it is further preferred that if one section instruction in any one instruction before all execution routes can guarantee it is new and old
Version semantic congruence, then section instruction is security update instruction set.
As it is further preferred that the update module specifically includes:
Pause unit, the update request for being issued according to user, suspends all processes relevant to update;
Static variable updating unit becomes for all legacy version static variables to be updated to be converted into new version static state
Amount;
Function updating unit, for checking whether function to be updated is located at function call stack, if so, according to the function language
Benefit film showing firing table, next binary instruction after modifying the current execution position of thread, by the current execution position stacking of thread, then
The entry address for generating intermediate auxiliary function is jumped to, is updated using intermediate auxiliary function;Otherwise, for being not in function
The function to be updated of call stack, is updated using the method for Modification growth function entry address.
As it is further preferred that the system also includes:
Memory module, for saving the checkpoint of program to be updated before program updates;
Monitoring module, at no point in the update process, monitoring program state to be updated in real time by monitoring programme;
Roll-back module, for being clicked through using the inspection saved in the memory module when program to be updated is abnormal
Row rollback, by state of the programe reduction to be updated to before updating.
In general, it is put above technical scheme is compared with the prior art according to the present invention, mainly has technology below
Advantage:
(1) versatility.The present invention is modified without carrying out special change to program to be updated in advance by trace tool
Active program, it is only necessary to modify partial binary in original program and jump, without the help of specific compiler, improve
The versatility of software dynamic update method;
(2) real-time.The present invention can be directly updated with any time in program any position, be transported without waiting for program
Row arrive security update point, thus effectively prevent call in function can not more news, while when multithread programs carry out
When update, it is updated again after need not also waiting whole threads to reach security update point;
(3) multithreading safety.The present invention enables multithread programs same by intermediate auxiliary function and transfer function
Moment completes dynamic and updates, and while guaranteeing the safety of multithreading update, the data for also ensuring that multithreading updates are consistent
Property, it further avoids using deadlock bring update unsafe problems occur after security update point, also avoids new and old edition
The inconsistence problems of data;
(4) user operability.The important work of the method for the present invention is all completed before the update, and work when update is all
It is completed by monitoring programme, is assisted without user.And those are judged update opportunity by user or are set by the user update condition
Conventional dynamic update method then needs user to grasp the relevant knowledge of a large amount of dynamic updates, therefore the method for the present invention is not necessarily to user
Grasping the relevant knowledge of any dynamic update can be completed software dynamic update;
(5) reliability.When dynamic update of software malfunctions, many dynamic update systems can not be restored to the state before updating,
It especially updates when unsuccessfully process is caused to be collapsed, this undoubtedly reduces the reliability of dynamic update of software, but passes through this hair
Bright method can make to update program quick rollback when the error occurs, to guarantee the reliability of software dynamic update;
(6) low overhead.Software dynamic update method originally often has excessive security update in program renewal process
Point and a large amount of code revisions work, such as storehouse reconstruct.And most work of the invention is all to carry out before the update,
Only seldom workload is needed to reduce update expense to substantially increase the efficiency of update in renewal process;
Detailed description of the invention
Fig. 1 is the flow chart of the software dynamic update method the present invention is based on intermediate auxiliary function;
Fig. 2 is that the present invention is based on the software dynamic update system block diagrams of intermediate auxiliary function;
Fig. 3 is the schematic illustration of security update instruction set;
Fig. 4 is the principle of compositionality schematic diagram of intermediate auxiliary function;
Fig. 5 (a) and (b) are rollback work flow diagram in the method for the present invention.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right
The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and
It is not used in the restriction present invention.
Integral Thought of the invention is that developer generates auxiliary comprising new function and centre according to the source code of new and old edition
The primary dynamic update patch for helping function solves traditional multithreading dynamic update using intermediate auxiliary function and needs to modify legacy version
Source code or the problem of legacy version source code is transformed using specific compiler.Then dynamic update patch is loaded when updating, temporarily
Stop all threads, is realized and jumped indirectly to realize that update is not in the to be updated of function call stack by Modification growth function entry address
Function.Next instruction is currently executed instruction by Modification growth function jumps it into intermediate auxiliary function, intermediate auxiliary by operation
Function is helped to carry out the update of completion code and variable in the function to be updated of function call stack.
As shown in Figure 1, the present invention is based on the multi-thread software dynamic update method of asynchronous checkpointing the following steps are included:
(1) legacy version code source file and new version of code source file are obtained, common intermediate language CIL is passed through
The pooling function of (Common Intermediate Language) integrates it respectively, the legacy version code source after being integrated
File and new version of code source file;
(2) it is generated by the dynamic patch of online upgrade system Polus (Powerful Live Updating System)
Tool compares the code source file of the legacy version code source file after integration and new version, generates primary dynamic update and mends
Fourth;
(3) letter to be updated in the legacy version code source file and new version of code source file after static analysis comparison integration
Number, analyzes the semanteme of function to be updated, generating function Semantic mapping table, while according to function to be updated, generates and intermediate assists letter
Number;This step specifically includes following sub-step:
(3-1) analyzes the semanteme of function to be updated, obtains and record the security update instruction set of function to be updated.Safety
If updating instruction set refers to that all execution routes in one section of instruction before any one instruction can guarantee new and old edition function
Semantic congruence, then section instruction is security update instruction set.In the methods of the invention, Core Generator discriminant function of the invention
Semantic congruence, which refers on new and old function execution route, only has the sequence of code and version inconsistent, remaining is all identical.To own
Whole security update instruction sets of function to be updated are recorded, generating function Semantic mapping table.Developer can also basis
The security update instruction set for needing Modification growth function Semantic mapping table of itself.
(3-2) using the parameter of function to be updated as the parameter of intermediate auxiliary function, construction generates intermediate auxiliary function.In
Between auxiliary function include control content, function new version content to be updated and function legacy version content to be updated.
Wherein, the control content is used for the local variable of function legacy version to be updated and Parameter Switch into new version
Local variable and parameter are also used to execute address according to thread when operation to judge whether the thread is in security update instruction set
It closes, if so, jumping into function new version content to be updated, is returned after executing function new version content to be updated;Otherwise, it jumps
Enter function legacy version content to be updated, when going to any one instruction in security update instruction set, then jumps into be updated
Function new version content;
That is control content is first by the local variable of function legacy version to be updated and Parameter Switch at new version
Local variable and parameter, thread currently executes address when then obtaining operation from stack, and the function in query steps (3-1) is semantic
Mapping table, it is contemplated that whether be in security update instruction set come thread present instruction when judging operation, if so, step can be passed through
Suddenly the function Semantic mapping table in (3-1) obtains currently performed address in the corresponding position of function new version content to be updated,
Then branch to the position, i.e., at runtime thread present instruction enter in security update instruction set (including sequence enter, lead to
Cross branch, recycle, jump entrance) sentence after skip instruction is added, so that it is jumped to function to be updated in intermediate auxiliary function
The corresponding position of new version content.;Otherwise, it jumps into function legacy version content corresponding position to be updated;
(3-3) modifies to the function legacy version content to be updated of the intermediate auxiliary function, makes it using conversion letter
Number access new version static variable, local variable and parameter.It is transformed that is, treating renewal function legacy version content,
The data to be updated of function legacy version access to content to be updated are all used into transfer function (i.e. adapter function) dereference.In
Between in auxiliary function function legacy version content to be updated be then to access new version data (packet by way of reading and writing fitness function
Include static variable, local variable and parameter).
(4) according to the initialization requests of user, the primary dynamic update patch generated in step (2) is injected into and is being transported
In capable program to be updated;
(5) it after injecting dynamic update patch, is obtained according to functional symbol name to be updated and static variable symbolic name to be updated
Corresponding function to be updated and static variable address to be updated in program to be updated;
(6) it is requested according to the update that user issues, suspends all processes relevant to update, and according to the to be updated of acquisition
Static variable address is updated static variable to be updated;Meanwhile checking whether function to be updated is located at function call stack, if
It is then to be updated using intermediate auxiliary function to the function to be updated for being located at function call stack;Otherwise directly to not in function
The function to be updated of call stack is updated;This step includes substep:
(6-1) is requested according to the update that user issues, and suspends all processes relevant to update, all legacy versions are waited for
It updates static variable and is converted into new version static variable;Update for static variable passes through general type, pointer type, number
Three kinds of different types of set type realize three kinds of different transfer functions respectively, and legacy version static variable to be updated is converted into newly
Version static variable;
(6-2) checks whether function to be updated is located at function call stack, if so, according to the function Semantic mapping of step (3)
Table, next binary instruction after modifying the current execution position of thread then branch to the current execution position stacking of thread
The entry address that intermediate auxiliary function is generated in step (3), is updated using intermediate auxiliary function;Otherwise, for being not in
The function to be updated of function call stack, is updated using the method for Modification growth function entry address.
The function to be updated for being not in function call stack is updated using the method for Modification growth function entry address.When program is run
When to function to be updated, jumps directly to corresponding new version function and be updated.Specifically, function to be updated is started
Binary code is substituted for jmp instruction, so that execution route is jumped to new version function, the parameter and local variable of function then use
The mode of redirection is mapped to the memory address of new version function.
To the function to be updated for being in function call stack, next after modifying the current execution position of thread is executed instruction,
It is set to jump to intermediate auxiliary function to complete to update the function called.It specifically will be under the current execution position of function to be updated
The binary system of one (ordinary circumstance is next of sequence, if present instruction is jump instruction, for the destination address jumped)
Instruction is substituted for jmp instruction, and execution route is made to jump to intermediate auxiliary function.The parameter and local variable of function are then used and are reset
To mode be mapped to the memory address of intermediate auxiliary function, while intermediate auxiliary function is recorded in the current execution position of thread
Storehouse in.
(7) restore the process being suspended by update, renewal process terminates.
The method of the present invention further include: when mistake occurring at no point in the update process, before making it roll back to update by monitoring programme
State.It specifically includes:
(1) checkpoint of program to be updated is saved before program updates;
(2) at no point in the update process, program state to be updated is monitored in real time by monitoring programme, if program to be updated generation is different
Chang Shi carries out rollback using the checkpoint, is reverted to the state before updating.
Fig. 2 show a kind of software dynamic update system based on intermediate auxiliary function corresponding with the above method, described
System includes:
Module is integrated, for obtaining and integrating legacy version code source file and new version of code source file, after obtaining integration
Legacy version code source file and new version of code source file;
Patch generation module, for passing through legacy version code source file and new version of code source file after comparison is integrated,
Generate primary dynamic update patch;
Analysis module, in the legacy version code source file and new version of code source file after static analysis comparison integration
Function to be updated, analyze the semanteme of function to be updated, generating function Semantic mapping table, while for according to function to be updated,
Generate intermediate auxiliary function;
The analysis module specifically includes:
First analysis generation unit obtains and records the safety of function to be updated for analyzing the semanteme of function to be updated
Update instruction set, generating function Semantic mapping table;Wherein, if security update instruction set refers in one section of instruction any one
All execution routes before instruction can guarantee new and old edition semantic congruence, then section instruction is security update instruction set.
Second analysis generation unit, for using the parameter of function to be updated as the parameter of intermediate auxiliary function, construction life
At intermediate auxiliary function, the intermediate auxiliary function includes control content, function new version content to be updated and function to be updated
Legacy version content;Wherein,
The control content is used for the part by the local variable of function legacy version to be updated and Parameter Switch at new version
Variable and parameter are also used to execute address according to thread when operation to judge whether the thread is in security update instruction set,
If so, jumping into function new version content to be updated, returned after executing function new version content to be updated;Otherwise, jump into
Function legacy version content to be updated is then jumped when going to any one instruction in security update instruction set into letter to be updated
Number new version content;
Unit is modified, is modified for the function legacy version content to be updated to the intermediate auxiliary function, its benefit is made
New edition notebook data is accessed with transfer function.
The primary dynamic update patch of generation is injected by injection module for the initialization requests according to user
In the program to be updated of operation;
Module is obtained, for becoming after injecting dynamic update patch according to functional symbol name to be updated and static state to be updated
Quantity symbol name obtains corresponding function to be updated and static variable address to be updated in program to be updated;
Update module, the update request for being issued according to user suspend all processes relevant to update, and according to obtaining
The static variable address to be updated taken is updated static variable to be updated;Meanwhile checking whether function to be updated is located at letter
Number call stack, if so, being updated using intermediate auxiliary function to the function to be updated for being located at function call stack;Otherwise directly
Function to be updated not in function call stack is updated;
The update module specifically includes:
Pause unit, the update request for being issued according to user, suspends all processes relevant to update;
Static variable updating unit becomes for all legacy version static variables to be updated to be converted into new version static state
Amount;
Function updating unit, for checking whether function to be updated is located at function call stack, if so, according to the function language
Benefit film showing firing table, next binary instruction after modifying the current execution position of thread, by the current execution position stacking of thread, then
Jump to the entry address for generating intermediate auxiliary function;Otherwise, for being not in the function to be updated of function call stack, using repairing
The method for changing function entrance address is updated.
Recovery module, the process for restoring to be suspended by update, renewal process terminate.
As it is further preferred that the system also includes:
Memory module, for saving the checkpoint of program to be updated before program updates;
Monitoring module, at no point in the update process, monitoring program state to be updated in real time by monitoring programme;
Roll-back module, for being clicked through using the inspection saved in the memory module when program to be updated is abnormal
Row rollback, by state of the programe reduction to be updated to before updating.
As shown in figure 3, at no point in the update process, some update positions are can to guarantee to be corresponding to it safety in new function more
New position such as updates point a, c.But in some update positions, new function it is no corresponding security update position
, such as update point b.If if non-security update position updates by force, will lead to function fun can be executed twice, thus
Lead to various unknowable mistakes.By analysis, when update point before all branches new and old edition function execution route all languages
When justice is consistent, it will not occur when updating at this time because sentence, which is omitted, updates unsafe acts caused by execution or extra execution.
In practice, security update position is often continuous, it is possible to which the mode for it being become range is recorded, formation function
Semantic mapping table.Query function Semantic mapping table can thus be passed through, it can be determined that running position whether be safety more
New position can also obtain the corresponding jump location of any one home by query function Semantic mapping table.
The construction of intermediate auxiliary function is as shown in figure 4, first by legacy version local variable and Parameter Switch at new edition local exchange
Then portion's variable and parameter obtain function from stack and currently execute address, the function Semantic mapping table in query steps (3-1),
It whether is in security update instruction set to judge that thread currently executes the instruction of address, if function currently executes the instruction of address
In security update instruction set, function can be obtained currently performedly by the function Semantic mapping table in step (3-1)
The corresponding position of location function new version content to be updated in intermediate auxiliary function, then branches to the position.If function is current
It executes address and is not at security update instruction set, then it is corresponding to jump function legacy version content to be updated in intermediate auxiliary function
Position.The intermediate next part of auxiliary function is the function to be updated of complete new version and waits for by improved legacy version
Renewal function.Function legacy version content to be updated enter security update instruction set (including sequence enter, by branch, circulation,
Jump entrance) sentence after skip instruction is added, so that it is jumped to intermediate auxiliary function function new version content to be updated corresponding
Part.At no point in the update process, it is assumed that function update status jumps as shown in Fig. 2, when function currently executes sentence statement4
To after intermediate auxiliary function, query statement statement4 is unsecure position, so jumping in function legacy version to be updated
Appearance continues to execute, when entering security update range when function legacy version content to be updated goes to the position statement6,
To jump to function new version content to be updated, the update work of the function is completed.Function to be updated is old in intermediate function
The data to be updated of release content access all use transfer function dereference, guarantee that all threads are all in multithread programs in this way
Same part data are accessed, to guarantee multithread programs data consistency
For the step schematic diagram of rollback as shown in figure 5, Fig. 5 (a) indicates to update program work step, Fig. 5 (b) indicates monitoring journey
Sequence work step.Before update, monitoring programme saves the checkpoint of program to be updated.In renewal process, there are two types of mechanism to find
Abnormal, one is carry out rollback by more new procedures error notification monitor.But if updating mistake is serious error (process
Collapse) when, more new procedures just can not notification monitor renewal process be abnormal.So the present invention provides another mechanism:
By the state of monitoring programme timing acquisition more new procedures, rollback is just carried out if noting abnormalities.Rollback process is saved using prior
Checkpoint by programe reduction to update before state.
As it will be easily appreciated by one skilled in the art that the foregoing is merely illustrative of the preferred embodiments of the present invention, not to
The limitation present invention, any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should all include
Within protection scope of the present invention.
Claims (6)
1. a kind of software dynamic update method based on intermediate auxiliary function, which is characterized in that the described method includes:
(1) it obtains and integrates legacy version code source file and new version of code source file, the legacy version code source after being integrated
File and new version of code source file;
(2) it by the legacy version code source file and new version of code source file after comparison integration, generates primary dynamic update and mends
Fourth;
(3) function to be updated in the legacy version code source file and new version of code source file after static analysis comparison integration,
Analyze the semanteme of function to be updated, generating function Semantic mapping table, while according to function to be updated, generate intermediate auxiliary function;
(4) according to the initialization requests of user, the primary dynamic update patch generated in step (2) is injected into and is currently running
In program to be updated;
(5) it after injecting dynamic update patch, is obtained according to functional symbol name to be updated and static variable symbolic name to be updated to more
Corresponding function to be updated and static variable address to be updated in new procedures;
(6) it is requested according to the update that user issues, suspends all processes relevant to update, and according to the static state to be updated of acquisition
Address of variable is updated static variable to be updated;Meanwhile checking whether function to be updated is located at function call stack, if so,
Then the function to be updated for being located at function call stack is updated using intermediate auxiliary function;Otherwise directly to not in function call
The function to be updated of stack is updated;
(7) restore the process being suspended by update, renewal process terminates;
The step (3) specifically includes:
(3-1) analyzes the semanteme of function to be updated, obtains and record the security update instruction set of function to be updated, generating function
Semantic mapping table;
(3-2) using the parameter of function to be updated as the parameter of intermediate auxiliary function, construction generates intermediate auxiliary function, it is described in
Between auxiliary function include control content, function new version content to be updated and function legacy version content to be updated;Wherein,
The control content is used for the local variable by the local variable of function legacy version to be updated and Parameter Switch at new version
And parameter, it is also used to execute address according to thread when operation to judge whether the thread is in security update instruction set, if so,
It then jumps into function new version content to be updated, is returned after executing function new version content to be updated;Otherwise, it jumps into be updated
Function legacy version content is then jumped when going to any one instruction in security update instruction set into function new edition to be updated
This content;
(3-3) modifies to the function legacy version content to be updated of the intermediate auxiliary function, visits it using transfer function
Ask new edition notebook data;
If all execution routes in one section of instruction before any one instruction can guarantee new and old edition semantic congruence, which refers to
Enabling is security update instruction set.
2. the method according to claim 1, wherein the step (6) specifically includes:
(6-1) is requested according to the update that user issues, and suspends all processes relevant to update, and all legacy versions is to be updated
Static variable is converted into new version static variable;
(6-2) checks whether function to be updated is located at function call stack, if so, being repaired according to the function Semantic mapping table of step (3)
The current execution position stacking of thread is then branched to step by next binary instruction after Cheng Dangqian execution position of relocating
(3) entry address of intermediate auxiliary function is generated in;Otherwise, for being not in the function to be updated of function call stack, using repairing
The method for changing function entrance address is updated.
3. the method according to claim 1, which is characterized in that the method also includes:
(1) checkpoint of program to be updated is saved before program updates;
(2) at no point in the update process, program state to be updated is monitored in real time by monitoring programme, if program to be updated is abnormal
When, rollback is carried out using the checkpoint, is reverted to the state before updating.
4. a kind of software dynamic update system based on intermediate auxiliary function, which is characterized in that the system comprises:
Module is integrated, it is old after being integrated for obtaining and integrating legacy version code source file and new version of code source file
Edition code source file and new version of code source file;
Patch generation module, for generating by the legacy version code source file and new version of code source file after comparison integration
Primary dynamic update patch;
Analysis module, for static analysis comparison integration after legacy version code source file and new version of code source file in
Renewal function analyzes the semanteme of function to be updated, generating function Semantic mapping table, while being used to be generated according to function to be updated
Intermediate auxiliary function;
The primary dynamic update patch of generation is injected into and is currently running for the initialization requests according to user by injection module
Program to be updated in;
Module is obtained, for being accorded with after injecting dynamic update patch according to functional symbol name to be updated and static variable to be updated
Number name obtains corresponding function to be updated and static variable address to be updated in program to be updated;
Update module, the update request for being issued according to user, suspends all processes relevant to update, and according to acquisition
Static variable address to be updated is updated static variable to be updated;Meanwhile checking whether function to be updated is located at function tune
With stack, if so, being updated using intermediate auxiliary function to the function to be updated for being located at function call stack;Otherwise directly to not
It is updated in the function to be updated of function call stack;
Recovery module, the process for restoring to be suspended by update, renewal process terminate;
The analysis module specifically includes:
First analysis generation unit obtains and records the security update of function to be updated for analyzing the semanteme of function to be updated
Instruction set, generating function Semantic mapping table;
Second analysis generation unit, used in using the parameter of function to be updated as the parameter of intermediate auxiliary function, construction to be generated
Between auxiliary function, the intermediate auxiliary function includes control content, function new version content to be updated and function old edition to be updated
This content;Wherein,
The control content is used for the local variable by the local variable of function legacy version to be updated and Parameter Switch at new version
And parameter, it is also used to execute address according to thread when operation to judge whether the thread is in security update instruction set, if so,
It then jumps into function new version content to be updated, is returned after executing function new version content to be updated;Otherwise, it jumps into be updated
Function legacy version content is then jumped when going to any one instruction in security update instruction set into function new edition to be updated
This content;
Unit is modified, is modified for the function legacy version content to be updated to the intermediate auxiliary function, it is utilized and turns
Change function access new edition notebook data;
If all execution routes in one section of instruction before any one instruction can guarantee new and old edition semantic congruence, which refers to
Enabling is security update instruction set.
5. system according to claim 4, which is characterized in that the update module specifically includes:
Pause unit, the update request for being issued according to user, suspends all processes relevant to update;
Static variable updating unit, for all legacy version static variables to be updated to be converted into new version static variable;
Function updating unit, for checking whether function to be updated is located at function call stack, if so, being reflected according to the function semanteme
Then firing table, next binary instruction after modifying the current execution position of thread jump the current execution position stacking of thread
To the entry address for generating intermediate auxiliary function;Otherwise, for being not in the function to be updated of function call stack, modification letter is used
The method of number entry address is updated.
6. such as the described in any item systems of claim 4-5, which is characterized in that the system also includes:
Memory module, for saving the checkpoint of program to be updated before program updates;
Monitoring module, at no point in the update process, monitoring program state to be updated in real time by monitoring programme;
Roll-back module, for being returned using the checkpoint saved in the memory module when program to be updated is abnormal
Rolling, by state of the programe reduction to be updated to before updating.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610039757.0A CN105528231B (en) | 2016-01-21 | 2016-01-21 | A kind of software dynamic update method and system based on intermediate auxiliary function |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610039757.0A CN105528231B (en) | 2016-01-21 | 2016-01-21 | A kind of software dynamic update method and system based on intermediate auxiliary function |
Publications (2)
Publication Number | Publication Date |
---|---|
CN105528231A CN105528231A (en) | 2016-04-27 |
CN105528231B true CN105528231B (en) | 2019-03-05 |
Family
ID=55770478
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610039757.0A Active CN105528231B (en) | 2016-01-21 | 2016-01-21 | A kind of software dynamic update method and system based on intermediate auxiliary function |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105528231B (en) |
Families Citing this family (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106980515B (en) | 2016-10-28 | 2020-04-14 | 阿里巴巴集团控股有限公司 | Application upgrading method and device |
CN108134763B (en) * | 2016-12-01 | 2021-07-13 | 南宁富桂精密工业有限公司 | Attack coping method and system |
CN107092496A (en) * | 2016-12-28 | 2017-08-25 | 北京小度信息科技有限公司 | The upgrade method and device of a kind of application software |
CN111124444B (en) * | 2018-11-01 | 2023-12-19 | 百度在线网络技术(北京)有限公司 | Method of code injection, apparatus therefor, computer program product, and storage medium |
CN109445823A (en) * | 2018-11-02 | 2019-03-08 | 长虹美菱股份有限公司 | A kind of MCU firmware fast updating method |
CN112114848A (en) * | 2020-09-11 | 2020-12-22 | 北京达佳互联信息技术有限公司 | Drive updating method, device, system, electronic equipment and storage medium |
CN112764788B (en) * | 2021-01-19 | 2023-06-16 | 南京大学 | Software dynamic update hot patch synthesis method based on program source code slice recombination |
CN113204356B (en) * | 2021-06-02 | 2023-11-07 | 吉林大学 | Application program dynamic updating method for vehicle-mounted embedded equipment |
CN113608846A (en) * | 2021-07-20 | 2021-11-05 | 阿里巴巴(中国)有限公司 | Data checking method, device and equipment of process stack |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101799763A (en) * | 2009-02-10 | 2010-08-11 | 华为技术有限公司 | Method, device and system for patching kernel on line |
US8793662B2 (en) * | 2008-03-25 | 2014-07-29 | Microsoft Corporation | Runtime code hooking for print driver and functionality testing |
CN103984582A (en) * | 2014-06-04 | 2014-08-13 | 网易(杭州)网络有限公司 | Method and device for hot updating |
CN104111848A (en) * | 2014-06-27 | 2014-10-22 | 华中科技大学 | Multi-thread software dynamic upgrading method based on asynchronous check points |
-
2016
- 2016-01-21 CN CN201610039757.0A patent/CN105528231B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8793662B2 (en) * | 2008-03-25 | 2014-07-29 | Microsoft Corporation | Runtime code hooking for print driver and functionality testing |
CN101799763A (en) * | 2009-02-10 | 2010-08-11 | 华为技术有限公司 | Method, device and system for patching kernel on line |
CN103984582A (en) * | 2014-06-04 | 2014-08-13 | 网易(杭州)网络有限公司 | Method and device for hot updating |
CN104111848A (en) * | 2014-06-27 | 2014-10-22 | 华中科技大学 | Multi-thread software dynamic upgrading method based on asynchronous check points |
Also Published As
Publication number | Publication date |
---|---|
CN105528231A (en) | 2016-04-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105528231B (en) | A kind of software dynamic update method and system based on intermediate auxiliary function | |
Lawall et al. | Coccinelle: 10 years of automated evolution in the Linux kernel | |
EP4004738B1 (en) | Time-travel debugging with hot code replacement | |
CN104111848B (en) | Multi-thread software dynamic upgrading method based on asynchronous check points | |
Wang et al. | Coverage guided systematic concurrency testing | |
Padioleau et al. | Documenting and automating collateral evolutions in Linux device drivers | |
US8689191B2 (en) | Correct refactoring of concurrent software | |
US20080244544A1 (en) | Using hardware checkpoints to support software based speculation | |
US8423970B2 (en) | Method, computer program product, and hardware product for handling breakpoints in an asynchronous debug model | |
CN101446918B (en) | Method for realizing debugging of single function by user state debugger and system thereof | |
Liu et al. | FCatch: Automatically detecting time-of-fault bugs in cloud systems | |
EP1208425A2 (en) | Computer system, computer-readable storage medium and method of operating same, and method of operating that system | |
WO2015117434A1 (en) | Method and device for manufacturing patch, and method and device for activating patch | |
CN100349131C (en) | Method for positioning malfunction of application program | |
CN103077111A (en) | Method and system for locating continuous integration failed case | |
Kim et al. | Dual execution for on the fly fine grained execution comparison | |
Visan et al. | URDB: a universal reversible debugger based on decomposing debugging histories | |
US9740597B2 (en) | Transactional execution of native methods | |
Spall et al. | Build scripts with perfect dependencies | |
Zhao et al. | Synthesizing object state transformers for dynamic software updates | |
Desnoyers et al. | Multi-core systems modeling for formal verification of parallel algorithms | |
Huang et al. | {PYLIVE}:{On-the-Fly} Code Change for Python-based Online Services | |
Bradbury et al. | Defining a catalog of programming anti-patterns for concurrent java | |
Ma et al. | Efficient Scheduler Live Update for Linux Kernel with Modularization | |
Baur | Instrumenting Java bytecode to replay execution traces of multithreaded programs |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |