Android device kernel vulnerability repairing system and methodTechnical Field
The invention relates to a technology in the field of computers, in particular to a system and a method for repairing kernel bugs of old Android equipment.
Background
Most of the kernel vulnerabilities found on Android today are logical vulnerabilities that are easy to patch and recompile on source code. In practice Google only pushes patch updates for its Nexus device. When Google releases a new security update, it often takes a significant amount of time for other vendors to update compatible mobile devices. In some cases, some vendors may even ignore certain updates or only update their own up-to-date devices. Therefore, in this case, a large number of Android devices will face a situation where vulnerabilities cannot be repaired for a long time.
One of the biggest obstacles to security updates for the Android system comes from Android system fragmentation. Compared with IOS devices, the Android system has a large number of different vendors, thus creating a variety of binary files. Moreover, most manufacturers close the source of the codes related to the devices, each manufacturer generates a certain fixed version based on the source codes by modifying or deleting related functions in a large amount, and some manufacturers optimize the binary codes by using different compilers or compiling options. In addition, the repair involves work such as binary rewriting, different protection means (kernel code read-only, kernel module check, kernel module white list, PXN and the like) are adopted for different manufacturers of kernel codes, and certain difficulty is caused to the rewriting work.
Disclosure of Invention
Aiming at the defects in the prior art, the invention provides a system and a method for repairing the kernel vulnerability of the Android device.
The invention is realized by the following technical inventions:
the invention relates to a system for repairing kernel bugs of Android equipment, which comprises the following components: the device comprises a repair information acquisition module, a heuristic matching module, a kernel page table processing module and a repair module, wherein: the restoration information acquisition module is connected with the heuristic matching module and transmits CVE (Common Vulnerabilities & expositions) information, the heuristic matching module is connected with the restoration module and transmits vulnerability point positions, namely insertion point positions of the restoration codes, the kernel page table processing module is connected with the restoration module and transmits the distributed executable memory information, and the restoration module realizes the restoration of Vulnerabilities according to the distributed executable memory information and vulnerability point positions.
The Android equipment is as follows: android system devices with version below 6.0.
The kernel vulnerability refers to a CVE vulnerability related to an android system kernel.
The invention relates to a method for repairing kernel bugs of the system, which comprises the following steps:
step 1) acquiring relevant repair information from the latest Android CVE information issued by the Android Security Bulletin of Google every month and acquiring kernel symbol information from the Android equipment to be repaired.
The repair information includes: functions with holes in the CVE and repair codes.
The acquiring kernel symbol information includes: all function addresses and names of kernels stored by kallsyms, i.e. kernel symbol information, are read from/proc/kallsyms on Android devices.
And 2) selecting a kernel page table of a certain unusual syscall, rewriting write permission and codes, triggering the system call to distribute executable memory, and finally restoring the kernel page table.
The uncommon syscall comprises: sys _ scheduled _ yield, etc.
The writing permission modification means that: and modifying the authority of the kernel page table according to different protection means adopted by different manufacturers, so that the kernel code area for placing the syscall can be written.
The code rewriting means: rewriting the syscall code, rewriting a shellcode (shell code) of the distributed executable memory according to the position of the kernel code of the syscall obtained by the kernel symbol information, so that an executable area for placing the patching code in the future in the kernel can be obtained when the syscall is called. The result of the call to syscall will return the address of the executable area.
And 3) positioning a function with a vulnerability according to the vulnerability repair information and the kernel symbol information, and then searching and positioning vulnerability points and vulnerability repair information through a heuristic matching strategy.
The positioning refers to: and positioning the function with the bug through the path/dev/kmem for accessing the kernel virtual memory.
The vulnerability repair information is as follows: the patch code refers to a register or memory address that stores the relevant variable.
The heuristic matching strategy can help the repair system to adaptively position bug points and bug repair information. The heuristic matching positioning strategy carries out matching according to the following characteristics: mnemonics and operators, constants, calling conventions, relative offsets of the architects, assembly code features of the ARM architecture, such as return, jump related instructions, etc.
And 4) generating a patching code according to the vulnerability points positioned by the heuristic matching strategy and the related patching information, rewriting and patching the vulnerability points, and placing the patching code on the executable area obtained in the step 2.
The vulnerability rewriting and modifying method specifically comprises the following steps:
A) modifying the page table authority of the vulnerability point code segment and increasing the write authority;
B) rewriting a jump instruction at the bug point and pointing the jump instruction to an executable area address;
C) the patch code is written in the executable area.
D) And restoring the page table authority of the vulnerability point code segment to a state before modification.
Drawings
FIG. 1 is a flow chart of the present invention;
FIG. 2 is a schematic diagram of the system of the present invention.
Detailed Description
As shown in fig. 2, the present embodiment includes: the device comprises a repair information acquisition module, a heuristic matching module, a kernel page table processing module and a repair module, wherein: the restoring information acquisition module is connected with the heuristic matching module and transmits CVE information, the heuristic matching module is connected with the restoring module and transmits the position of a bug point, namely the insertion point position of a restoring code, the kernel page table processing module is connected with the restoring module and transmits distributed executable memory information, and the restoring module realizes restoring of the bug according to the distributed executable memory information and the location of the bug point.
As shown in fig. 1, the present embodiment relates to a method for repairing the above system, which includes the following steps:
step 1) acquiring repair information related to CVE from safety announcement issued by Google every month;
and 2) selecting a kernel page table of a certain unusual syscall, rewriting write permission and codes, triggering system call to distribute executable memory, and finally restoring the kernel page table.
And 3) positioning a function with the vulnerability according to the patching information and the kernel symbol information, and then searching and positioning vulnerability points and related vulnerability patching information through a heuristic matching strategy.
And 4) generating a patching code according to the vulnerability points positioned by the heuristic matching strategy and the related patching information, rewriting and patching the vulnerability points, and placing the patching code on the executable area obtained in the step 2.
In the heuristic matching strategy, the matched features comprise: mnemonics and operators, constants, calling conventions, relative offsets of the architects, and assembly code features of the ARM architecture, such as return, jump related instructions, etc.
The rewriting modification comprises the following steps:
1) for the kernel, there are two ways to make the kernel code read-only. One is the configure DEBUG data option, which employs a single-level mapping to the page table. The other is the high-pass CONFIG _ stride _ MEMORY _ RWX option, with page mapping.
2) After rewriting the page table, the kernel code is directly modified to crash. Through research and analysis, each process copies a region of a kernel page table at the time of establishment, so code modification is performed by newly starting one process.
3) The short term modification of the selected syscall does not affect the normal use of the system.
Through the above strategy, the invention directly carries out dynamic repair on the kernel code under the condition of no source code. Compared with the previous research invention and the research on the actual mobile equipment condition, most of the equipment below 6c.0 can be repaired.
The foregoing embodiments may be modified in many different ways by those skilled in the art without departing from the spirit and the principle of the invention, and the scope of the invention is not limited by the above embodiments but by the appended claims.