Kernel security protection method and device

By screening and processing malicious programs and setting memory page tags to control their access permissions, the problem of kernel security risks is solved and network security defense capabilities are improved.

CN118585993APending Publication Date: 2024-09-03ZHEJIANG E COMMERCE BANK CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410592185.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-13
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

There is little domestic research and resources on the abuse of technology that allows program logic to be loaded into the kernel without restarting and updating, resulting in kernel security risks, and professionals’ insufficient understanding of its potential threats, affecting the construction of a network security defense system.

Method used

By filtering out malicious programs, using the auxiliary functions provided by the operating system kernel to access memory pages, and invalidating malicious programs, at the same time, setting preset marks for the memory pages to be protected, responding to memory access operations to control access rights, and preventing malicious programs from proceeding. Malicious activities.

Benefits of technology

It effectively protects the security of kernel data, avoids kernel security risks, and enhances network security defense capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118585993A
    Figure CN118585993A
Patent Text Reader

Abstract

The embodiment of the invention provides a kernel security protection method and device, and the method comprises the steps: screening out a malicious program, enabling the malicious program to access a memory page through an auxiliary function provided by an operating system kernel, carrying out the failure processing of the malicious program, setting a preset mark for the to-be-protected memory page, and carrying out the protection of the to-be-protected memory page. And in response to a memory access operation of the auxiliary function, controlling the memory access operation according to a preset mark of a memory page to be accessed by the memory access operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present specification relate to the field of computer technology, and in particular to a kernel security protection method and device. Background Art

[0002] As the core of cloud computing, data centers, and high-performance computing, the Linux kernel has gained widespread popularity. With the rapid advancement and growing complexity of cloud-native technologies, kernel security faces challenges.

[0003] Currently, a technology has emerged that allows program logic to be loaded into the kernel and updated without restarting, significantly improving the flexibility and responsiveness of the system. Although this technology has helped solve many technical problems, it can also be used maliciously. There is little research and resources on the abuse of this technology in China, and domestic professionals are not aware of its potential threats, which may put domestic companies at a disadvantage when building a network security defense system, posing a threat to network security.

[0004] In view of this, a kernel security protection method is urgently needed to avoid kernel security risks. Summary of the invention

[0005] In view of this, an embodiment of this specification provides a kernel security protection method. One or more embodiments of this specification also involve a kernel security protection device, a computing device, a computer-readable storage medium and a computer program product to solve the technical problem of kernel security risks existing in the prior art.

[0006] According to the first aspect of the embodiments of the present specification, a kernel security protection method is provided, comprising: screening out malicious programs, which access memory pages through auxiliary functions provided by an operating system kernel; performing invalidation processing on the malicious programs; setting a preset mark for the memory page to be protected; and in response to the memory access operation of the auxiliary function, controlling the memory access operation according to the preset mark of the memory page to be accessed by the memory access operation.

[0007] According to the second aspect of the embodiments of the present specification, a kernel security protection device is provided, including: a detection module, configured to screen out malicious programs, which access memory pages through auxiliary functions provided by the operating system kernel; a first defense module, configured to invalidate the malicious programs; a mark setting module, configured to set a preset mark for the memory page to be protected; and a second defense module, configured to respond to the memory access operation of the auxiliary function and control the memory access operation according to the preset mark of the memory page to be accessed by the memory access operation.

[0008] According to a third aspect of an embodiment of this specification, a computing device is provided, including: a memory and a processor; the memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions, which implement the steps of the above-mentioned kernel security protection method when executed by the processor.

[0009] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the above-mentioned kernel security protection method are implemented.

[0010] According to a fifth aspect of the embodiments of this specification, a computer program product is provided, including a computer program / instruction, which implements the steps of the above-mentioned kernel security protection method when executed by a processor.

[0011] An embodiment of the present specification provides a kernel security protection method. Since the method filters out malicious programs from the system, the malicious programs can be implemented based on the technology that allows program logic to be loaded into the kernel and does not require restarting and updating. Based on such technology, the malicious program needs to access the memory page through an auxiliary function. In order to protect the kernel security, the method invalidates the malicious program, which can prevent the malicious program from performing malicious activities in the kernel, and sets a preset mark for the memory page to be protected. In response to the memory access operation of the auxiliary function, the memory access operation is controlled according to the preset mark of the memory page to be accessed by the memory access operation. In this way, as long as the preset mark is set on the memory page to be protected as needed, the malicious program can be prevented from performing malicious activities by controlling the memory access operation, such as preventing the malicious program from obtaining memory data, thereby effectively protecting the data security of the kernel and effectively avoiding kernel security risks. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 This is a schematic diagram of an application scenario of a kernel security protection method provided by an embodiment of this specification;

[0013] Figure 2 It is a flowchart of a kernel security protection method provided by an embodiment of this specification;

[0014] Figure 3 It is a process flow chart of a kernel security protection method provided by an embodiment of this specification;

[0015] Figure 4 It is a structural schematic diagram of a kernel security protection device provided by an embodiment of this specification;

[0016] Figure 5 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION

[0017] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0018] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0019] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0020] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0021] First, the terms involved in one or more embodiments of this specification are explained.

[0022] eBPF (extended Berkeley Packet Filter) is a technology that can run sandboxed programs in a privileged context, such as an operating system kernel. It is used to safely and efficiently extend the functionality of the kernel at runtime without changing the kernel source code or loading kernel modules. Security is provided by a kernel verifier that performs static code analysis and rejects programs that crash, hang, or otherwise negatively interfere with the kernel. Verified loaded programs are interpreted or compiled by the kernel's JIT (Just In Time) to obtain native execution performance. eBPF use cases include XDP (XML Data Package), tracing, and security subsystems.

[0023] Rootkit: A rootkit is a collection of computer software, usually malicious, designed to give unauthorized users access to a computer or its software areas, and often to mask its presence or the presence of other software. Rootkit is a combination of "root" (the traditional name for a privileged account on Unix-like operating systems) and "kit" (a set of tools, referring to the software components that implement the tool). Rootkit installation can be automated, or an attacker can install it after gaining root or administrator access. Gaining root privileges is the result of a direct attack on the system, either by exploiting a vulnerability (such as privilege escalation) or by passwords (such as by cracking). Once installed, it is possible to hide the intrusion and maintain privileged access. Control over the system means that existing software can be modified, including malicious attack software.

[0024] LKM (Loadable Kernel Module), a loadable kernel module is an object file that contains code used to extend the running kernel of an operating system. LKMs are often used to add support for new hardware (such as device drivers) or file systems. When the functionality provided by an LKM is no longer needed, it can be uninstalled to free up memory and other resources.

[0025] At present, although the technology that allows program logic to be safely loaded into the kernel and updated without restarting has significantly improved the flexibility and responsiveness of the system, it can also be used maliciously. There is little research and resources on the abuse of this technology in China, and domestic professionals are not aware of its potential threats, which may put domestic companies at a disadvantage when building a network security defense system, posing a threat to network security.

[0026] In view of this, in this specification, a kernel security protection method is provided. This specification also involves a kernel security protection device, a computing device, a computer program product and a computer-readable storage medium to avoid kernel security risks, which are described in detail one by one in the following embodiments.

[0027] See also Figure 1 , Figure 1 The following is a schematic diagram showing an application scenario of a kernel security protection method provided according to an embodiment of this specification. Figure 1 As shown, the application scenario may include: operating system kernel space 110. Correspondingly, the operating system also includes user space. Based on the technology that allows program logic to be loaded into the kernel and updated without restarting, the kernel manages the eBPF program through the prog_idr object in the kernel. The entity that performs activities in the kernel of the eBPF program is the bpf_prog object, that is, the bpf_prog object runs in the operating system kernel space 110 and performs entity behaviors such as memory access. eBPF can provide a safe way to enhance the functionality of the kernel or perform kernel-level debugging. Auxiliary functions are some predefined functions in the kernel that can be called in the eBPF program. These auxiliary functions provide some commonly used functions, such as mathematical operations, memory access, etc. According to the kernel security protection method provided in the embodiment of this specification, a loadable kernel module LKM is implemented, and the LKM can be loaded into the kernel before running. After the loadable kernel module LKM is run in the kernel, the LKM can screen out malicious eBPF programs, perform invalidation processing on the malicious eBPF programs (such as deleting the program, releasing the bpf_prog object, intercepting malicious behavior, etc.), and set a preset mark for the memory page to be protected. In response to the memory access operation of the auxiliary function, the memory access operation is controlled according to the preset mark of the memory page to be accessed by the memory access operation. For example, a defense strategy can be added to the auxiliary function to control the auxiliary function from accessing the memory page with a preset prohibited access mark.

[0028] Since the loadable kernel module LKM filters out malicious eBPF programs, based on the technology that allows program logic to be loaded into the kernel without restarting and updating, the eBPF program accesses the memory page through the auxiliary function. In order to protect the kernel security, the method invalidates the malicious eBPF program, which can prevent malicious eBPF from performing malicious activities in the kernel, and sets a preset mark for the memory page to be protected. In response to the memory access operation of the auxiliary function, the memory access operation is controlled according to the preset mark of the memory page to be accessed by the memory access operation. For example: a defense strategy can be added to the auxiliary function used to access the memory in advance, so that the auxiliary function cannot access the memory page with a preset prohibited access mark. In this way, as long as the preset mark is set for the memory page to be protected, the memory access operation of the auxiliary function can be controlled. For example, for the memory page to be protected, as long as the memory page has a preset prohibited access mark, the malicious eBPF program can be prevented from obtaining memory data, effectively protecting the data security of the kernel and effectively avoiding kernel security risks.

[0029] It should be noted that the above embodiment only uses eBPF program to illustrate malicious programs and an optional application scenario of the kernel security protection method. The malicious program can be any program based on the technology that allows program logic to be loaded into the kernel without restarting and updating. The operating system kernel can be the operating system kernel of any server or any terminal device.

[0030] See also Figure 2 , Figure 2 A flowchart of a kernel security protection method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0031] Step 202: Filter out malicious programs, wherein the malicious programs access memory pages through auxiliary functions provided by the operating system kernel.

[0032] The kernel is the core of an operating system. It is usually the first-layer software expansion based on hardware. It provides the most basic functions of the operating system and is responsible for managing the system's processes, memory, device drivers, files, and network systems, etc., and determines the system's performance and stability.

[0033] Based on the technology that allows program logic to be loaded into the kernel and updated without restarting, some types of programs can effectively expand the functionality of the kernel at runtime without changing the kernel source code or loading kernel modules. Since such programs can load program logic into the kernel without restarting and updating, they may be used maliciously to perform malicious activities, such as attacking the system or stealing data, etc. Such programs can be understood as malicious programs described in this specification. For example: the malicious programs may include but are not limited to eBPF programs that perform malicious activities. In view of this, in this step, it is necessary to screen out malicious programs in order to eliminate the risks brought by these malicious programs.

[0034] In the embodiments of this specification, the specific method of screening malicious programs is not limited. For example, in some embodiments, the screening is performed by analyzing the behavior of malicious programs; in other embodiments, the screening is performed by comparing a preset whitelist with program information.

[0035] Taking the implementation of the preset whitelist as an example, the screening of malicious programs may include:

[0036] Query the program information of the running programs that meet the preset query conditions;

[0037] Compare the program information with the program information in a preset whitelist to obtain a comparison result;

[0038] According to the comparison result, the program corresponding to the program information not in the preset whitelist is regarded as a malicious program.

[0039] The preset query condition can be set according to the common characteristics of malicious programs that often appear in application scenarios. For example, in some application scenarios, the malicious program is usually manifested as an eBPF program, and the iconic object managed by the eBPF program in the kernel is the prog_idr object. Therefore, in this application scenario, the preset query condition can be to query the prog_idr object in the kernel.

[0040] The program information is program identity information used to represent the program identity, and is used to compare with the program information in a preset whitelist. Therefore, the information type of the program information to be queried is usually set according to the information type of the program information provided in the preset whitelist, and may include but is not limited to: field content of certain key fields, keywords, etc.

[0041] Taking the malicious program as an eBPF program as an example: the step of querying the program information of the running program that meets the preset query conditions may include: traversing the prog_idr object in the kernel, thereby obtaining the field content of the key fields of the bpf_prog objects of all eBPF programs loaded in the kernel. Among them, the key fields include but are not limited to any one or more fields of the bpf_prog object, such as prog_id (program identifier), prog_type (program type), attach_type (attachment type), process_id (process identifier), and user_id (user identifier).

[0042] The preset whitelist is used to distinguish between programs that perform safe activities and programs that perform malicious activities in the kernel, which may include program information of programs that meet the preset query conditions and perform safe activities. It is understandable that, since the preset whitelist includes program information of programs that perform safe activities, correspondingly, programs that are not in the preset whitelist and meet the preset query conditions can be regarded as malicious programs that perform malicious activities. For a program that meets the preset query conditions, the comparison result may include: the program information is in the preset whitelist, or the program information is not in the preset whitelist. By screening out malicious programs in the form of a preset report list and detecting malicious programs based on a predefined whitelist in a specific scenario, the detection performance can be effectively improved, and the problems of incomplete detection coverage, false alarms of malicious programs, etc. that may exist in other screening methods such as blacklist methods and behavior analysis methods can be avoided.

[0043] Step 204: invalidate the malicious program.

[0044] The failure process refers to the process of making the malicious activities of the malicious program incapable of being active. The failure process may include any one or more processing methods. For example, in some embodiments, the malicious program may be directly removed from the kernel; in other embodiments, the key objects of the malicious program may be released (also referred to as removed) to make it invalid; in still other embodiments, the behavior of the malicious program may be intercepted and prevented to make it invalid.

[0045] In one or more embodiments of this specification, the invalidation process of the malicious program includes:

[0046] Release the designated key object of the malicious program.

[0047] The designated key object is a key component of the malicious program, which encapsulates the program code of part or all of the behavior of the malicious program. This part can be a process, some data, or some more abstract entities. For example, for the eBPF program, the designated key object is the bpf_prog object. By releasing the designated key object, there is no need to care about other parts of the malicious program, which can achieve the effect of making the malicious program invalid as soon as possible, which is equivalent to achieving the purpose of quickly deleting the malicious program and effectively ensuring kernel security.

[0048] Step 206: Setting a preset mark for the memory page to be protected.

[0049] The preset mark is control information for controlling the access rights of the corresponding memory page. Since the page table entry of the memory page is used to store the mapping from the virtual page number to the physical page number and the control information, the preset mark can be set in the page table entry of the memory page. Of course, it can also be set in other ways, and this specification does not limit this. The expression form of the preset mark is not limited, and it can be represented by any characters, such as letters and / or numbers. In one or more embodiments, when the preset mark is used to indicate prohibited access, the preset mark can be expressed as a preset prohibited access mark represented by the number "1". In one or more other embodiments, when the preset mark is used to indicate permitted access, the preset mark can be expressed as a preset permitted access mark represented by the number "0".

[0050] Based on the different control requirements for read operations and / or write operations in different application scenarios, the control meaning represented by the preset mark can be set as needed. For example: for memory pages that you want to prevent malicious eBPF programs from accessing, you can add a preset prohibit access mark to the page table entry of the memory page to indicate that access is prohibited. When the auxiliary function is called by a malicious eBPF program to access a memory page with a preset prohibit access mark, the access operation is prohibited, which can prevent the malicious eBPF program from obtaining the data in the memory page. For another example: for memory pages that you want to prevent malicious eBPF from reading, you can add a preset prohibit read access mark to the page table entry of the memory page. For another example: for memory pages that you want to prevent malicious eBPF from writing, you can add a preset prohibit write access mark to the page table entry of the memory page.

[0051] Step 208: In response to the memory access operation of the auxiliary function, control the memory access operation according to a preset tag of a memory page to be accessed by the memory access operation.

[0052] The auxiliary function is an interface provided by the kernel to developers, and is a function used for programs such as eBPF to interact with other modules of the kernel. Since programs such as eBPF can only call auxiliary functions provided by the kernel to access memory, it can prevent the above-mentioned programs such as eBPF from improperly accessing memory, causing system crashes or security vulnerabilities, and ensure system security. For example, in the Linux operating system, auxiliary functions related to memory access include but are not limited to: bpf_probe_read_user (a function that reads data from user space), bpf_probe_write_user (a function that writes data to user space), bpf_probe_read_kernel (a function that reads kernel data), and other functions.

[0053] The memory access operation refers to an operation of accessing memory, which may include a read operation and / or a write operation on memory data.

[0054] The memory page is the basic unit of memory paging. For example, the memory can be divided into pages of fixed size, one memory page is usually 4KB, and the running of a program usually occupies at least one memory page.

[0055] Taking the preset mark as a preset access prohibition mark for indicating access prohibition as an example, the memory access operation in response to the auxiliary function is controlled according to the preset mark of the memory page to be accessed by the memory access operation, including:

[0056] Preliminarily adding a defense strategy to an auxiliary function for accessing memory, the defense strategy at least comprising: in a case where a memory page to be accessed by a memory access operation has a preset access prohibition mark, prohibiting the memory access operation from accessing the memory page;

[0057] In response to the memory access operation of the auxiliary function, according to the defense strategy, if the memory page to be accessed by the memory access operation has a preset access prohibition mark, the memory access operation is prohibited from accessing the memory page.

[0058] The defense strategy can be expressed as a program that can be executed in the auxiliary function, which is triggered by the memory access operation of the auxiliary function. If the memory page to be accessed by the memory access operation has a preset prohibited access mark, the memory access operation is prohibited from accessing the memory page.

[0059] In the above embodiment, by adding a defense strategy in the auxiliary function, the memory access mechanism of programs such as eBPF that may perform malicious activities is modified, which can effectively ensure that the parameters and return data of the memory pages of the protected program are not maliciously obtained or modified.

[0060] It should be noted that controlling the memory access operation according to the preset mark is not limited to the above-mentioned implementation method of adding a defense strategy in the auxiliary function. In other implementation methods, the memory access operation program code of the auxiliary function can also be directly modified to the logic of the above-mentioned defense strategy. In some other implementation methods, the memory access operation of the auxiliary function can also be intercepted outside the auxiliary function, and the logic of the above-mentioned defense strategy is executed outside the auxiliary function. For example: an additional interception program can be set to intercept the memory access operation of the auxiliary function. When the memory page to be accessed by the memory access operation has a preset prohibited access mark, the memory access operation is directly blocked. When the memory page to be accessed by the memory access operation does not have a preset prohibited access mark, the memory access operation is released.

[0061] It can be seen that since this method filters out malicious programs from the system, malicious programs can be implemented based on the technology that allows program logic to be loaded into the kernel and updated without restarting. Based on such technology, malicious programs need to access memory pages through auxiliary functions. In order to protect the security of the kernel, this method invalidates the malicious program, which can prevent malicious programs from performing malicious activities in the kernel, and responds to the memory access operation of the auxiliary function. According to the preset mark of the memory page to be accessed by the memory access operation, the memory access operation is controlled. In this way, as long as the preset mark is set in the memory page to be protected, the malicious program can be prevented from performing malicious activities by controlling the memory access operation, such as preventing the malicious program from obtaining memory data, thereby effectively protecting the data security of the kernel and effectively avoiding kernel security risks.

[0062] It can be understood that the preset prohibited access mark is a mark that can be recognized by the defense strategy provided in the embodiment of this specification. When a certain memory page needs to be protected, the memory page can be set as a memory page with a preset prohibited access mark, so that the defense strategy prohibits memory access operations from accessing the memory page. In this embodiment, if a certain memory page does not need to be protected, there is no need to set a preset prohibited access mark for the memory page, so that the defense strategy allows memory access operations to access the memory page, thereby ensuring that the memory page that is not in the defense state can be normally accessed by the auxiliary function.

[0063] Specifically, the defense strategy further includes: when the memory page to be accessed by the memory access operation does not have a preset access prohibition mark, allowing the memory access operation to access the memory page; accordingly, in response to the memory access operation of the auxiliary function, controlling the memory access operation according to the preset mark of the memory page to be accessed by the memory access operation, including:

[0064] In response to the memory access operation of the auxiliary function, according to the defense strategy, if the memory page to be accessed by the memory access operation does not have a preset access prohibition mark, the memory access operation is allowed to access the memory page.

[0065] For example: a general memory page usually has a free bit in the page table entry, and the free mark of the free bit is "0" by default, indicating free, when it is not modified. According to the above embodiment, when the memory page needs to be protected, the "0" of the free bit in the page table entry of the memory page can be changed to a preset prohibited access mark "1", and when the memory page does not need to be protected, the free bit "0" can be kept unchanged. In this way, in the above embodiment, according to the defense strategy, if the value of the free bit of the memory page to be accessed by the memory access operation is "1", the memory access operation is prohibited from accessing the memory page. If the value of the free bit is not "1" (that is, it is "0"), it can be determined that the memory page does not have a preset prohibited access mark, and the memory access operation is allowed to access the memory page.

[0066] There are many implementations of the defense strategy allowing memory access operations to access memory pages, which are not limited to the above-mentioned implementation of identifying memory pages without preset prohibited access marks. For example: In other implementations, for memory pages that are not in a defense state, a preset allowed access mark can be additionally set to enable the defense strategy to identify and allow access. By identifying that the memory page does not have a preset prohibited access mark to allow access, there is no need to make special settings for the memory page, which has the effect of achieving a simpler and more efficient effect.

[0067] According to the method provided in the embodiment of this specification, for the memory page to be protected, a preset access prohibition mark can be added to it. Specifically, the setting of the preset mark for the memory page to be protected includes:

[0068] Determine the memory page to be protected;

[0069] Determine the free bits of the page table entry of the memory page to be protected;

[0070] The free mark in the free bit of the page table entry of the memory page to be protected is modified to the preset access prohibition mark.

[0071] There are many ways to set a preset access-forbidden mark for a memory page, and this specification does not limit this. Since the page table entry of the memory page is used to store the mapping of the virtual page number to the physical page number and the control information. There are free bits for the control information in the page table entry, so the preset mark can be set in the free bits of the page table entry of the memory page, so as to effectively use the page table entry to realize the control of the memory access operation, which is simpler and more efficient.

[0072] In one or more embodiments of this specification, in order to further protect the security of the kernel, some programs may also be protected.

[0073] Specifically, the method further includes:

[0074] Determine the program components to be protected;

[0075] The program component to be protected is added to a set of untraceable programs of the kernel.

[0076] The program component to be protected may be all or part of any one or more programs running in the kernel. The untraceable program set may also be understood as a blacklist of untraceable program components maintained by the kernel, and program components added to the blacklist cannot be tracked (tracking is also called hook). For example, method components such as query, screening and deletion methods of the program to be protected may be marked as untraceable.

[0077] In one or more other embodiments of the present specification, the method further includes: deleting reference information of a designated key object used to reference the malicious program.

[0078] The reference information is the information that other programs can obtain from the malicious program when other programs reference (which can be expressed as loading or mounting) the specified key object of the malicious program. The obtained information is called reference information. Since these reference information may contain relevant data obtained when the malicious program performs malicious activities, such as file descriptors, directory entries, etc., by deleting the reference information, it is possible to effectively prevent kernel data from being maliciously stolen.

[0079] The following combination Figure 3 , taking the application of the kernel security protection method provided in this specification in detecting and removing malicious eBPF programs as an example, the kernel security protection method is further described. Among them, Figure 3 A flowchart of a process of a kernel security protection method provided by an embodiment of the present specification is shown. In this embodiment, a dynamically loaded kernel module implemented by the method provided by the embodiment of the present specification can be preloaded, and the dynamically loaded kernel module performs the following steps.

[0080] Step 302: Add a defense strategy to the auxiliary function used to access memory in advance.

[0081] The defense strategy at least includes: when the memory page to be accessed by the memory access operation has a preset access prohibition mark, prohibiting the memory access operation from accessing the memory page. By adding a defense strategy to the auxiliary function, the memory access control method of eBPF is improved, which can effectively prevent malicious eBPF programs from modifying parameters or returning data to the protected program during runtime.

[0082] Step 304: Determine a memory page to be protected, and modify the free flag in the free bit of the page table entry of the memory page to be protected to the preset access-forbidden flag.

[0083] This step modifies the free bits of the page table entry of the memory page to be protected, and can use the free bits to control the eBPF program to read or write sensitive memory pages to be protected through auxiliary functions.

[0084] Step 306: Traverse the prog_idr objects in the operating system kernel, determine all eBPF programs in the operating system, and obtain the corresponding bpf_prog objects.

[0085] In this step, by traversing the prog_idr object in the kernel, it is equivalent to querying all the eBPF programs running in the system, so that malicious eBPF programs can be filtered out based on the preset whitelist in the following step.

[0086] For example, you can call the kernel-provided method to loop through the prog_idr objects in the kernel and save the returned result (such as the address of the bpf_prog object) in a pointer variable, so that after the traversal is completed, you can obtain all the bpf_prog objects saved by the pointer variable.

[0087] Step 308: Compare the key fields of the queried bpf_prog object with the key fields in the preset whitelist to obtain a comparison result.

[0088] For example, the key fields of the bpf_prog object stored in the pointer variable can be compared with the key fields in the preset whitelist, which include but are not limited to the prog_id, prog_type, attach_type, process_id, user_id and other fields of the eBPF program.

[0089] In different application scenarios, the content of the preset whitelist may be different, that is, in different application scenarios, the normally active programs may be different. In addition, the program information in the preset whitelist, such as key fields, can also be customized according to needs, and this specification does not limit this. For example: the method of obtaining the preset whitelist is not limited, for example, you can manually add a safe eBPF program, or obtain a list of safe eBPF programs in the system through the system management information, and so on.

[0090] Malicious eBPF programs are screened out by comparing with a preset whitelist, which can ensure that the programs in the preset whitelist can use the various functions of eBPF normally without restricting the functions of normal eBPF programs. It can complete the detection and defense of malicious eBPF programs without affecting the availability of normal eBPF programs.

[0091] Step 310: According to the comparison result, determine that the bpf_prog object corresponding to the key field not in the preset hundred list is the designated key object of the malicious program.

[0092] It should be noted that for a bpf_prog object, if the object has multiple key fields, then if all key fields do not match the preset whitelist, the corresponding bpf_prog object is determined to be the bpf_prog object of a malicious program. If at least one key field matches, it may be a normal eBPF program, and the next bpf_prog object will be traversed until all bpf_prog objects are traversed.

[0093] Step 312: Delete the reference information of the bpf_prog object of the malicious program referenced by other programs in the kernel.

[0094] The reference information may be in the form of a file descriptor, a directory entry, etc. of the malicious program. More specifically, the reference of the file descriptor may be released first, that is, first checking whether there is a file descriptor pointing to the malicious eBPF program in the system, if so, deleting the file descriptor pointing to the malicious eBPF program, then checking whether there is a directory entry pointing to the malicious eBPF program, if so, deleting the directory entry pointing to the malicious eBPF program, and finally, entering step 314.

[0095] Step 314: Release the bpf_prog object of the malicious program.

[0096] Releasing the bpf_prog object is equivalent to removing the malicious eBPF program.

[0097] Step 316: Determine the program component to be protected, and add the program component to be protected to the untraceable set maintained by the kernel.

[0098] In this step, by adding the protected program components to the untraceable set maintained by the kernel, the data confidentiality of the protected program components during runtime is ensured, and the relevant data will not be obtained by malicious eBPF programs, thereby achieving defense reinforcement for the protected program components.

[0099] Step 318: In response to the memory access operation of the auxiliary function, if the memory page to be accessed by the memory access operation has a preset access prohibition mark, the memory access operation is prohibited from accessing the memory page; otherwise, the memory access operation is allowed to access the memory page.

[0100] Based on the protection strategy, this step determines whether the memory page has a preset prohibition mark, and prohibits or allows access based on the judgment result. The memory access control mechanism of the eBPF program is modified to prevent the runtime data of the protected program from being modified or obtained, thereby improving the integrity of the runtime data.

[0101] In the above embodiment, by dynamically loading the kernel module to execute the above process, the normal programs in the preset whitelist can fully utilize all the features provided by eBPF, without hindering the normal use of normal eBPF program functions, and can widely identify and defend against various types of potential malicious eBPF programs, with strong applicability, and enhance the real-time security of the Linux operating system kernel. In addition, through the anti-tracking of untraceable sets and the addition of defense strategies specifically for auxiliary functions used by eBPF programs, multiple defense effects are achieved, which greatly improves the difficulty of attackers to bypass, greatly enhances the security of the program from the bottom, and realizes the eBPF Rootkit detection and protection solution based on the whitelist mechanism.

[0102] Corresponding to the above method embodiment, this specification also provides a kernel security protection device embodiment, Figure 4 FIG. 1 is a schematic diagram showing the structure of a kernel security protection device provided by an embodiment of the present specification. Figure 4 As shown, the device comprises:

[0103] The detection module 402 is configured to filter out malicious programs that access memory pages through auxiliary functions provided by the operating system kernel.

[0104] The first defense module 404 is configured to perform an invalidation process on the malicious program.

[0105] The tag setting module 406 is configured to set a preset tag for the memory page to be protected.

[0106] The second defense module 408 is configured to respond to the memory access operation of the auxiliary function and control the memory access operation according to a preset tag of the memory page to be accessed by the memory access operation.

[0107] Since the device filters out malicious programs from the system, the malicious programs can be implemented based on the technology that allows program logic to be loaded into the kernel and updated without restarting. Based on such technology, the malicious program needs to access the memory page through the auxiliary function. In order to protect the security of the kernel, the method invalidates the malicious program, which can prevent the malicious program from performing malicious activities in the kernel, and responds to the memory access operation of the auxiliary function. According to the preset mark of the memory page to be accessed by the memory access operation, the memory access operation is controlled. In this way, as long as the preset mark is set in the memory page to be protected, the malicious program can be prevented from performing malicious activities by controlling the memory access operation, such as preventing the malicious program from obtaining memory data, thereby effectively protecting the data security of the kernel and effectively avoiding kernel security risks.

[0108] In one or more embodiments of the present specification, the preset mark includes: a preset access prohibition mark for indicating that access is prohibited. The second defense module includes:

[0109] The strategy adding submodule is configured to pre-add a defense strategy to the auxiliary function for accessing memory, wherein the defense strategy at least includes: if the memory page to be accessed by the memory access operation has a preset access prohibition mark, prohibiting the memory access operation from accessing the memory page;

[0110] The access prohibition submodule is configured to respond to the memory access operation of the auxiliary function and, according to the defense strategy, prohibit the memory access operation from accessing the memory page if the memory page to be accessed by the memory access operation has a preset access prohibition mark.

[0111] In one or more embodiments of the present specification, the defense strategy further includes: if the memory page to be accessed by the memory access operation does not have a preset access prohibition mark, allowing the memory access operation to access the memory page. The second defense module also includes:

[0112] The access permission submodule is configured to respond to the memory access operation of the auxiliary function and, according to the defense strategy, allow the memory access operation to access the memory page if the memory page to be accessed by the memory access operation does not have a preset access prohibition mark.

[0113] In one or more embodiments of the present specification, the mark setting module is configured to determine a memory page to be protected, and modify the free mark in the free bit of the page table entry of the memory page to be protected to the preset access prohibition mark.

[0114] In one or more embodiments of the present specification, the device further includes: an anti-tracing module configured to determine a program component to be protected, and add the program component to be protected to a set of untraceable programs of the kernel.

[0115] In one or more embodiments of this specification, the detection module includes:

[0116] A query submodule is configured to query program information of running programs that meet preset query conditions;

[0117] A whitelist comparison submodule is configured to compare the program information with the program information in a preset whitelist to obtain a comparison result;

[0118] The malicious determination submodule is configured to, based on the comparison result, identify the program corresponding to the program information not in the preset whitelist as a malicious program.

[0119] In one or more embodiments of the present specification, the first defense module is configured to release the designated key object of the malicious program.

[0120] In one or more embodiments of the present specification, the device further includes: a third defense module configured to delete reference information of a designated key object used to reference the malicious program.

[0121] The above is a schematic scheme of a kernel security protection device of this embodiment. It should be noted that the technical scheme of the kernel security protection device and the technical scheme of the kernel security protection method described above belong to the same concept, and the details of the technical scheme of the kernel security protection device that are not described in detail can all be referred to the description of the technical scheme of the kernel security protection method described above.

[0122] Figure 5 The structure block diagram of a computing device 500 provided according to an embodiment of the present specification is shown. The components of the computing device 500 include but are not limited to a memory 510 and a processor 520. The processor 520 is connected to the memory 510 via a bus 530, and the database 550 is used to store data.

[0123] The computing device 500 also includes an access device 540 that enables the computing device 500 to communicate via one or more networks 560. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 540 may include one or more of any type of network interface (e.g., a network interface card (NIC)) that is wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, and a near field communication (NFC).

[0124] In one embodiment of the present specification, the above components of the computing device 500 and Figure 5 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 5 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0125] The computing device 500 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 500 may also be a mobile or stationary server.

[0126] The processor 520 is used to execute the following computer program / instructions, which implement the steps of the above-mentioned kernel security protection method when executed by the processor.

[0127] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computing device embodiment, since it is basically similar to the kernel security protection method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the kernel security protection method embodiment.

[0128] An embodiment of the present specification also provides a computer-readable storage medium storing a computer program / instruction, which implements the steps of the above-mentioned kernel security protection method when executed by a processor.

[0129] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computer-readable storage medium embodiment, since it is basically similar to the kernel security protection method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the kernel security protection method embodiment.

[0130] An embodiment of the present specification also provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned kernel security protection method when executed by a processor.

[0131] The above is a schematic scheme of a computer program product of this embodiment. It should be noted that the technical scheme of the computer program product and the technical scheme of the kernel security protection method described above are of the same concept, and the details not described in detail in the technical scheme of the computer program product can be found in the description of the technical scheme of the kernel security protection method described above.

[0132] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0133] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0134] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0135] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0136] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.

Claims

1. A kernel security protection method, comprising: Screening out malicious programs, wherein the malicious programs access memory pages through auxiliary functions provided by the operating system kernel; Performing invalidation processing on the malicious program; Set a preset mark for the memory page to be protected; In response to the memory access operation of the auxiliary function, the memory access operation is controlled according to a preset tag of a memory page to be accessed by the memory access operation.

2. The method according to claim 1, wherein the preset mark comprises: A preset no-access mark used to indicate that access is prohibited; The step of controlling the memory access operation in response to the auxiliary function according to a preset tag of a memory page to be accessed by the memory access operation comprises: Preliminarily adding a defense strategy to an auxiliary function for accessing memory, the defense strategy at least comprising: in a case where a memory page to be accessed by a memory access operation has a preset access prohibition mark, prohibiting the memory access operation from accessing the memory page; In response to the memory access operation of the auxiliary function, according to the defense strategy, if the memory page to be accessed by the memory access operation has a preset access prohibition mark, the memory access operation is prohibited from accessing the memory page.

3. The method according to claim 2, wherein the defense strategy further comprises: When a memory page to be accessed by a memory access operation does not have a preset access prohibition mark, allowing the memory access operation to access the memory page; The step of controlling the memory access operation in response to the auxiliary function according to a preset tag of a memory page to be accessed by the memory access operation comprises: In response to the memory access operation of the auxiliary function, according to the defense strategy, if the memory page to be accessed by the memory access operation does not have a preset access prohibition mark, the memory access operation is allowed to access the memory page.

4. The method according to claim 2, wherein the step of setting a preset mark for the memory page to be protected comprises: Determine the memory page to be protected; The free mark in the free bit of the page table entry of the memory page to be protected is modified to the preset access prohibition mark.

5. The method according to claim 1, further comprising: Determine the program components to be protected; The program component to be protected is added to a set of untraceable programs of the kernel.

6. The method according to claim 1, wherein filtering out malicious programs comprises: Query the program information of the running programs that meet the preset query conditions; Compare the program information with the program information in a preset whitelist to obtain a comparison result; According to the comparison result, the program corresponding to the program information not in the preset whitelist is regarded as a malicious program.

7. The method according to claim 1, wherein the invalidation process of the malicious program comprises: Release the designated key object of the malicious program.

8. The method according to claim 7, further comprising: The reference information of the designated key object used to reference the malicious program is deleted.

9. A kernel security protection device, comprising: A detection module configured to filter out malicious programs that access memory pages through auxiliary functions provided by the operating system kernel; A first defense module is configured to perform invalidation processing on the malicious program; A tag setting module, configured to set a preset tag for the memory page to be protected; The second defense module is configured to respond to the memory access operation of the auxiliary function and control the memory access operation according to a preset mark of a memory page to be accessed by the memory access operation.

10. A computing device comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer program / instructions are executed by the processor, the steps of the kernel security protection method described in any one of claims 1 to 8 are implemented.

11. A computer-readable storage medium storing a computer program / instruction, which implements the steps of the kernel security protection method described in any one of claims 1 to 8 when executed by a processor.

12. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the kernel security protection method according to any one of claims 1 to 8.