CN104915209A - Method for trace debugging and problem repairing of Linux kernels - Google Patents

Method for trace debugging and problem repairing of Linux kernels Download PDF

Info

Publication number
CN104915209A
CN104915209A CN201510330712.4A CN201510330712A CN104915209A CN 104915209 A CN104915209 A CN 104915209A CN 201510330712 A CN201510330712 A CN 201510330712A CN 104915209 A CN104915209 A CN 104915209A
Authority
CN
China
Prior art keywords
function
repair
driver module
kernel
prefix
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.)
Pending
Application number
CN201510330712.4A
Other languages
Chinese (zh)
Inventor
李智荣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Feixun Data Communication Technology Co Ltd
Original Assignee
Shanghai Feixun Data Communication Technology Co Ltd
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 Shanghai Feixun Data Communication Technology Co Ltd filed Critical Shanghai Feixun Data Communication Technology Co Ltd
Priority to CN201510330712.4A priority Critical patent/CN104915209A/en
Publication of CN104915209A publication Critical patent/CN104915209A/en
Pending legal-status Critical Current

Links

Abstract

The invention provides a method for trace debugging and problem repairing of Linux kernels, which comprises the following steps: a problem function is repaired, a prefix is added before an original function name of the problem function to be defined to be a repair function, a driving module is created, and is arranged in a system device, a repair function with the prefix which is defined in a module is found out in an initialization function of the driving module, and function addresses of the problem function and the repair function are found out in a kernel symbol table, and an entry instruction of the problem function is repaired, and is executed by jumping to the repair function. Problem function repair codes are compiled and chained to be a Linux driving module, a kernel function which is needed to be repaired in identified in the driving module, a kernel inner function which is identified by the driving module is found out when the driving module is uploaded in a Linux kernel, and then the entry instruction of the kernel inner function is repaired, and jumps to the repair function which is defined by the driving module to execute, thereby being capable of repairing tracing, debugging and repairing problems of the repair function, solving the problem that debugging and repairing are difficult ago, and improving efficiency.

Description

A kind of method of linux kernel trace debug and the problem of reparation
Technical field
The present invention relates to Ethernet Exchanger Technology field, particularly relate to a kind of method of linux kernel trace debug and the problem of reparation.
Background technology
The problem debugging method that current submersible linux relates to kernel mainly recompilates whole kernel or uses KGDB (kernel GNU Debugger) software.Recompilate whole kernel consuming time long, and KGDB software to build environment more numerous and diverse and need kernel support.These two kinds of methods of what is more important need updating apparatus system version, and then restart system ability reparation problem, this is unallowed in some cases, as some client's critical network does not allow suspension.
Existing relate to embedded Linux kernel issue track, debugging and reparation method mainly there is following problem: recompilating whole linux kernel needs burning again, restarts device systems and consuming time long.Use KGDB except building circumstance complication, cannot support to change larger amendment.
Summary of the invention
The technical matters that the present invention need solve overcomes above-mentioned deficiency, provides the method for a kind of linux kernel trace debug with the problem of reparation, comprising:
Amendment problem function, adds prefix, is defined as repair function before problem function original function name;
Create driver module;
Driver module is installed in system equipment;
The repair function with described prefix of inside modules definition is searched inside the initialization function of driver module;
Search problem the function address of function and repair function in Kernel Symbol Table, and the entry instruction of amendment problem function, jumps to repair function and perform.
Further, described prefix is prefix_.
Further, the step of described establishment driver module is specially the described repair function of compiling and is linked as driver module.
Further, described driver module called after linux_kernel.ko.
Further, described method also comprises:
First old instruction is saved in an array before modify instruction;
From described array, recover the instruction before amendment during unloading driver module, recover the call flow of original function.
After adopting technical scheme of the present invention, problem function amendment code compilation is linked into a linux driver module, in driver module, mark needs the kernel function of amendment, when linux kernel loads driver module, find the kernel intrinsic function that described driver module identifies, then the entry instruction of this function is revised, the repair function jumping to our driver module definition performs, so just, can follow the tracks of inside this repair function, debug and repair problem, solve debugging in the past and repair the problem of difficulty, improve efficiency.
Accompanying drawing explanation
Fig. 1 is the method schematic diagram of linux kernel trace debug provided by the invention and the problem of reparation;
Fig. 2 is linux kernel original function call relation schematic diagram provided by the invention;
Fig. 3 is linux kernel function call relation schematic diagram provided by the invention.
Embodiment
Technical scheme of the present invention is understood better in order to make relevant technical staff in the field, below in conjunction with the accompanying drawing of embodiment of the present invention, technical scheme in embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.
Below in conjunction with drawings and embodiments, the invention will be further described.
Consult Fig. 1, a kind of linux kernel trace debug provided by the invention and the method for the problem of reparation, comprise the following steps:
Step S100, amendment problem function, adds prefix, is defined as repair function before problem function original function name;
As shown in Figure 2, the function call flow process of linux kernel far away is: function_a → function_b → function_c.Need to repair debugging if now function_b goes wrong, then problem function f unction_b is copied to a new original, revise described problem function f unction_b.After having revised, rename, prefixing before original function name, in the present embodiment, prefix is prefix_, i.e. prefix_function_b, and definition prefix_function_b is repair function.
Step S200, creates driver module;
Concrete, compile above-mentioned repair function prefix_function_b and be linked as driver module, by driver module called after linux_kernel.ko.
Step S300, is installed to driver module in system equipment;
The linux_kernel.ko that step S200 generates is installed in system equipment.
Step S400, searches the repair function with described prefix of inside modules definition inside the initialization function of driver module;
Search inside the initialization function of linux_kernel.ko driver module inside definition, the function of the prefix of name band in steps in S100, in the present embodiment, find prefix_function_b, just can think that prefix_function_b is used to repair function function_b by prefix " prefix_ ".
Step S500, the function address of search problem in Kernel Symbol Table function and repair function, the entry instruction of amendment problem function, jumps to repair function and performs.
As shown in Figure 3, after driver module is installed, find the position of function_b according to prefix_function_b during initialization, originally function_a is called function_b be revised as and call prefix_function_b, jump to function_c after prefix_function_b executes to perform, such function call flow process is just become from original function_a → function_b → function_c: function_a → prefix_function_b → function_c.
In a preferred embodiment, described linux kernel trace debug also comprises with the method for the problem of reparation:
First old instruction is saved in an array before modify instruction;
From described array, recover the instruction before amendment during unloading driver module, recover the call flow of original function.
In debug process, if pinpointing the problems is not appear at problem function, and need to recover original function calling relationship, then first old instruction being saved in an array before modify instruction is a measure insured very much.
After adopting technical scheme of the present invention, problem function amendment code compilation is linked into a linux driver module, in driver module, mark needs the kernel function of amendment, when linux kernel loads driver module, find the kernel intrinsic function that described driver module identifies, then the entry instruction of this function is revised, the repair function jumping to our driver module definition performs, so just, can follow the tracks of inside this repair function, debug and repair problem, solve debugging in the past and repair the problem of difficulty, improve efficiency.
Below only have expressed several embodiment of the present invention, it describes comparatively concrete and detailed, but therefore can not be interpreted as the restriction to the scope of the claims of the present invention.It should be pointed out that for the person of ordinary skill of the art, without departing from the inventive concept of the premise, can also make some distortion and improvement, these all belong to protection scope of the present invention.Therefore, the protection domain of patent of the present invention should be as the criterion with claims.

Claims (5)

1. linux kernel trace debug and a method for the problem of reparation, is characterized in that, comprising:
Amendment problem function, adds prefix, is defined as repair function before problem function original function name;
Create driver module;
Driver module is installed in system equipment;
The repair function with described prefix of inside modules definition is searched inside the initialization function of driver module;
Search problem the function address of function and repair function in Kernel Symbol Table, and the entry instruction of amendment problem function, jumps to repair function and perform.
2. the method for linux kernel trace debug according to claim 1 and the problem of reparation, it is characterized in that, described prefix is prefix_.
3. the method for linux kernel trace debug according to claim 1 and the problem of reparation, the step of described establishment driver module is specially the described repair function of compiling and is linked as driver module.
4. linux kernel trace debug according to claim 3 and the method for the problem of reparation, is characterized in that, described driver module called after linux_kernel.ko.
5. the method for linux kernel trace debug according to claim 1 and the problem of reparation, it is characterized in that, described method also comprises:
First old instruction is saved in an array before modify instruction;
From described array, recover the instruction before amendment during unloading driver module, recover the call flow of original function.
CN201510330712.4A 2015-06-15 2015-06-15 Method for trace debugging and problem repairing of Linux kernels Pending CN104915209A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510330712.4A CN104915209A (en) 2015-06-15 2015-06-15 Method for trace debugging and problem repairing of Linux kernels

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510330712.4A CN104915209A (en) 2015-06-15 2015-06-15 Method for trace debugging and problem repairing of Linux kernels

Publications (1)

Publication Number Publication Date
CN104915209A true CN104915209A (en) 2015-09-16

Family

ID=54084293

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510330712.4A Pending CN104915209A (en) 2015-06-15 2015-06-15 Method for trace debugging and problem repairing of Linux kernels

Country Status (1)

Country Link
CN (1) CN104915209A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105204998A (en) * 2015-09-30 2015-12-30 上海斐讯数据通信技术有限公司 Debugging method and device for mobile terminal kernel symbol table
CN105550575A (en) * 2015-12-03 2016-05-04 北京神州绿盟信息安全科技股份有限公司 Method and device for obtaining un-exported function address and data structure offset
CN106055979A (en) * 2016-05-24 2016-10-26 百度在线网络技术(北京)有限公司 Kernel fixing method and apparatus
CN106203072A (en) * 2016-06-30 2016-12-07 北京金山安全软件有限公司 Method and device for repairing driver and electronic equipment
CN108415840A (en) * 2018-03-14 2018-08-17 百度在线网络技术(北京)有限公司 The method, apparatus and server of repair function defect
CN111881455A (en) * 2020-07-27 2020-11-03 绿盟科技集团股份有限公司 Firmware security analysis method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101281488A (en) * 2007-04-06 2008-10-08 上海宇梦通信科技有限公司 Inner core debug method of Linux operating system
CN102722438A (en) * 2012-06-01 2012-10-10 北京神州绿盟信息安全科技股份有限公司 Kernel debugging method and equipment
CN104461625A (en) * 2014-12-04 2015-03-25 上海斐讯数据通信技术有限公司 Hot patch realization method and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101281488A (en) * 2007-04-06 2008-10-08 上海宇梦通信科技有限公司 Inner core debug method of Linux operating system
CN102722438A (en) * 2012-06-01 2012-10-10 北京神州绿盟信息安全科技股份有限公司 Kernel debugging method and equipment
CN104461625A (en) * 2014-12-04 2015-03-25 上海斐讯数据通信技术有限公司 Hot patch realization method and system

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105204998A (en) * 2015-09-30 2015-12-30 上海斐讯数据通信技术有限公司 Debugging method and device for mobile terminal kernel symbol table
CN105550575A (en) * 2015-12-03 2016-05-04 北京神州绿盟信息安全科技股份有限公司 Method and device for obtaining un-exported function address and data structure offset
CN105550575B (en) * 2015-12-03 2018-10-02 北京神州绿盟信息安全科技股份有限公司 A kind of acquisition methods and device of not derived function address and data structural deflection
CN106055979A (en) * 2016-05-24 2016-10-26 百度在线网络技术(北京)有限公司 Kernel fixing method and apparatus
CN110110522A (en) * 2016-05-24 2019-08-09 百度在线网络技术(北京)有限公司 Kernel restorative procedure and device
CN110110522B (en) * 2016-05-24 2021-05-07 百度在线网络技术(北京)有限公司 Kernel repairing method and device
CN106203072A (en) * 2016-06-30 2016-12-07 北京金山安全软件有限公司 Method and device for repairing driver and electronic equipment
CN106203072B (en) * 2016-06-30 2019-05-03 珠海豹趣科技有限公司 A kind of method, apparatus and electronic equipment for repairing driver
CN108415840A (en) * 2018-03-14 2018-08-17 百度在线网络技术(北京)有限公司 The method, apparatus and server of repair function defect
CN111881455A (en) * 2020-07-27 2020-11-03 绿盟科技集团股份有限公司 Firmware security analysis method and device
CN111881455B (en) * 2020-07-27 2023-12-01 绿盟科技集团股份有限公司 Firmware security analysis method and device

Similar Documents

Publication Publication Date Title
CN104915209A (en) Method for trace debugging and problem repairing of Linux kernels
CN102663285B (en) Extracting method and extracting device for APK (android package) virus characteristic code
CN105630557B (en) Hot patch method and apparatus
CN106933609B (en) Android application program installation package generation method and device
CN102567049B (en) The upgrade method of embedded OS
CN105446712B (en) Application program defect repairing method and device
CN105159738A (en) Hot patch implementation method and system
CN103473067A (en) Embedded Linux partitioning and data recovery method, embedded Linux partitioning and data recovery system and system development method
CN105045568A (en) System and method for an optimized operation of real-time embedded solutions in industrial automation
JPWO2013145105A1 (en) Sequence program debugging support device
CN111638884B (en) Method, system, device and storage medium for plug-in engineering compilation
CN102799437A (en) Automatic generating method and device of compiling script
CN102364433B (en) Method for realizing Wine construction tool transplanting on ARM (Advanced RISC Machines) processor
CN103645888A (en) System and method for automatically building operation system
KR20150132929A (en) Apparatus for Program Management of Programmable Logic Controller
CN105573913A (en) Program debugging method and program debugging system in optical network unit (ONU) system
CN102722438A (en) Kernel debugging method and equipment
CN105260184B (en) A kind of adjustment method and device for restoring image file
CN107273750B (en) Android device kernel vulnerability repairing system and method
CN103927213A (en) File compiling method and device
CN110647349B (en) Method for realizing continuous delivery of iOS APP
CN103631585A (en) Method and system for developing application program
CN104951290A (en) Method and equipment for optimizing software
CN109828786B (en) Automated tool based on code-level support sw _64 architecture
CN105159696A (en) Method and apparatus for realizing hardware drive independent of Linux kernel

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20150916