A system call processing method, apparatus, device, and medium
By determining the container's namespace in the cloud system kernel and using eBPF technology to generate a system call whitelist, the problem of low efficiency in recording container system call information is solved, achieving fast and automated whitelist generation and efficient system call management.
Patent Information
- Application Number
- CN202310296153.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-23
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2043-03-23
AI Technical Summary
In existing technologies, the recording of system call information for containers relies on system call whitelist collection tools and requires manual intervention, which is inefficient. Furthermore, the frequent transmission of process events between the kernel and user space leads to reduced execution efficiency and increased memory consumption.
By determining the namespace of containers in the cloud system kernel, recording system call information to the corresponding data structure of the namespace, and using eBPF technology to build a mapping relationship between container identifiers and namespace identifiers, a system call whitelist is automatically generated, reducing the transmission of process events between the kernel and user space.
It enables rapid and automated determination of container system call whitelists, improves the execution efficiency of kernel and user-space code, reduces memory consumption, and ensures the integrity and accuracy of the whitelist.
Smart Images

Figure CN116339918B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a system call processing method, apparatus, device and medium. Background Technology
[0002] Currently, the system call list for containers relies on system call whitelist (abbreviation for system call) collection tools (such as sysdig) to complete information recording. Furthermore, recording container system call information requires the participation of experienced business personnel and kernel developers; manual intervention is prone to errors and is inefficient. Moreover, existing solutions require the system kernel to frequently transmit every process event in the container to user-space programs so that these programs can record each process ID. This reduces the execution efficiency of both kernel and user-space code and increases memory consumption.
[0003] Therefore, how to quickly determine the system calls of a container is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a system call processing method, apparatus, device, and medium to quickly determine the system calls of a container. The specific solution is as follows:
[0005] Firstly, this application provides a system call processing method, applicable to the system kernel of any node in a cloud system, including:
[0006] When testing a target container, determine the namespace to which the target container belongs;
[0007] If the target container initiates a system call during the test, the corresponding system call information will be recorded in the data structure corresponding to the namespace.
[0008] Optionally, determining the namespace to which the target container belongs includes:
[0009] Query the file mount directory of the target container;
[0010] The namespace is determined based on the file mount directory.
[0011] Optionally, it also includes:
[0012] If a process starts for the first time in the target container, then the step of determining the namespace to which the target container belongs, and all subsequent steps, are executed.
[0013] Optionally, it also includes:
[0014] During the test, the process ID of any process in the target container and the space identifier of the namespace are transmitted to the user-space process, so that the user-space process can determine the container identifier of the target container based on the process ID and construct a mapping relationship between the container identifier and the space identifier.
[0015] Optionally, it also includes:
[0016] If the test ends, the data structure is transmitted to the user-space process so that the user-space process can collect the system call information of the target container based on the mapping relationship and the data structure, and obtain the collection results.
[0017] Optionally, after obtaining the collection results, the method further includes:
[0018] The collected results are synchronized to other nodes in the cloud system.
[0019] Optionally, before recording the corresponding system call information into the data structure corresponding to the namespace, the method further includes:
[0020] Determine whether the data structure exists in the system kernel;
[0021] If it exists, then the step of recording the corresponding system call information into the data structure corresponding to the namespace is executed; otherwise, after creating the data structure in the system kernel, the step of recording the corresponding system call information into the data structure corresponding to the namespace is executed.
[0022] Secondly, this application provides a system call processing method applicable to any node in a cloud system, including:
[0023] Obtain the system call whitelist of the target container; the system call whitelist is obtained based on any of the data structures described above.
[0024] Based on the system call whitelist and the target container's operating mode, process the system calls made during the target container's operation.
[0025] Optionally, processing system calls during the execution of the target container based on the system call whitelist and the target container's operating mode includes:
[0026] If the target container is running in monitoring mode, then when a system call not recorded in the system call whitelist occurs during the operation of the target container, an abnormal alarm will be issued for the current system call.
[0027] If the target container is in protected mode, then when a system call not recorded in the system call whitelist occurs during the operation of the target container, the current system call is intercepted; or when a system call not recorded in the system call whitelist occurs during the operation of the target container, the danger level of the current system call is assessed, and an abnormal alarm, interception, or release is issued for the current system call based on the danger level.
[0028] Optionally, before obtaining the system call whitelist of the target container, the method further includes:
[0029] After receiving the start command from the target container, wait for a preset time.
[0030] If the wait times out, then proceed with the steps of obtaining the system call whitelist of the target container; and processing the system calls made during the operation of the target container based on the system call whitelist and the operating mode of the target container.
[0031] Optionally, it also includes:
[0032] After creating a new container of the same type as the target container, use the system call whitelist as the system call whitelist for the new container.
[0033] Optionally, if the image, namespace, and business tag of the newly created container are all the same as those of the target container, then the newly created container and the target container belong to the same type of container.
[0034] Optionally, after processing the system calls during the execution of the target container based on the system call whitelist and the target container's operating mode, the method further includes:
[0035] The corresponding processing results will be synchronized to other nodes in the cloud system.
[0036] Optionally, it also includes:
[0037] If an update message for the system call whitelist is detected in the database, the latest system call whitelist is read from the database and replaced with the latest system call whitelist.
[0038] Thirdly, this application provides a system call processing apparatus, applied to the system kernel of any node in a cloud system, comprising:
[0039] The determination module is used to determine the namespace to which the target container belongs when testing the target container;
[0040] The recording module is used to record the corresponding system call information to the data structure corresponding to the namespace if the target container initiates a system call during the test.
[0041] Fourthly, this application provides a system call processing device, applicable to any node in a cloud system, comprising:
[0042] The acquisition module is used to acquire the system call whitelist of the target container; the system call whitelist is obtained based on the data structure described above.
[0043] The processing module is used to process system calls during the operation of the target container based on the system call whitelist and the target container's operating mode.
[0044] Fifthly, this application provides an electronic device, comprising:
[0045] Memory, used to store computer programs;
[0046] A processor for executing the computer program to implement the aforementioned disclosed method.
[0047] Sixthly, this application provides a readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned disclosed method.
[0048] As can be seen from the above scheme, this application provides a system call processing method, which is applied to the system kernel of any node in a cloud system, including: when testing a target container, determining the namespace to which the target container belongs; if the target container initiates a system call during the test, recording the corresponding system call information into the data structure corresponding to the namespace.
[0049] Since containers require testing before deployment, and testing containers typically involves thoroughly testing all their functionalities, all necessary system calls will occur during the testing process. Therefore, when testing a container, determining the target container's namespace and recording the corresponding system call information of system calls initiated by the target container during testing into the container's namespace data structure allows for the aggregation and recording of container system call information. This approach not only completes container testing but also yields a system call whitelist for the container. As can be seen, this application eliminates the need to specifically run containers to determine their system call whitelists, and the entire process is automated with low technical difficulty, enabling rapid determination of container system call whitelists. Furthermore, since containers are generally comprehensively tested, the system call whitelist ultimately determined through the testing process is relatively complete. This application distinguishes different containers within the node's system kernel by their namespaces, thereby differentiating the corresponding data structures for recording system call information for each container. Therefore, it eliminates the need to differentiate or focus on different processes within containers, and avoids frequent transmission of process events between the system kernel and user-space programs. This improves the execution efficiency of kernel and user-space code and reduces memory consumption.
[0050] Accordingly, the system call processing device, equipment, and readable storage medium provided in this application also have the above-mentioned technical effects. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0052] Figure 1 This is a flowchart of a system call processing method disclosed in this application;
[0053] Figure 2 This is a flowchart of another system call processing method disclosed in this application;
[0054] Figure 3 This is a schematic diagram illustrating the implementation process of a learning mode, monitoring mode, and protection mode disclosed in this application;
[0055] Figure 4 This is a schematic diagram of a system call recording process under a learning mode disclosed in this application;
[0056] Figure 5 This is a schematic diagram of the system call detection process under a monitoring mode and a protection mode disclosed in this application;
[0057] Figure 6 This is a schematic diagram of a system call processing device disclosed in this application;
[0058] Figure 7 This is a schematic diagram of another system call processing device disclosed in this application;
[0059] Figure 8 This is a schematic diagram of an electronic device disclosed in this application;
[0060] Figure 9 This is a schematic diagram of another electronic device disclosed in this application. Detailed Implementation
[0061] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0062] Currently, recording container system call information relies on system call whitelist (abbreviation for system call) collection tools (such as sysdig). This process requires experienced business personnel and kernel developers, and manual intervention is prone to errors and inefficient. Furthermore, existing solutions require the kernel to frequently transmit events for each process within the container to user-space programs, enabling these programs to record each process ID. This reduces the execution efficiency of both kernel and user-space code and increases memory consumption. Therefore, this application provides a system call processing solution that can quickly determine the container's system call whitelist and use this whitelist to alert / intercept abnormal container system calls.
[0063] See Figure 1 As shown in the figure, this application discloses a system call processing method, applied to the system kernel of any node in a cloud system, including:
[0064] S101. When testing the target container, determine the namespace to which the target container belongs.
[0065] In this embodiment, to record system call information for different containers, the namespace of each container is first determined. Different containers can reside in different or the same namespace; containers in different namespaces are isolated from each other, while containers in the same namespace are interconnected. Generally, a container contains multiple processes; recording the system call information of a container means recording the system call information of each process within that container.
[0066] In one implementation, determining the namespace to which the target container belongs includes: querying the target container's file mount directory; and determining the namespace (mntns) based on the file mount directory. Each container has its own corresponding file mount directory and can only see the file mount directory (i.e., the file system mount point) of its own namespace. Different processes within the same container have the same mntns; that is, each container has its own unique mntns.
[0067] S102. If the target container initiates a system call during the test, the corresponding system call information will be recorded in the data structure corresponding to the namespace.
[0068] In this embodiment, the data structure can be a BPF Map, which uses the namespace identifier of the container as the key and all system call information within the container as the value.
[0069] This embodiment records the system call information of the container in the system kernel of the node. Therefore, when a process first starts in the container (i.e., when the first process starts after the container starts), the namespace to which the target container belongs can be determined. Then, the process ID of the first started process and the namespace identifier of the container are transmitted to the user-space process of the current node. This allows the user-space process to determine the container identifier based on the process ID and construct a mapping relationship between the container identifier and the namespace identifier. This mapping relationship is used to determine the data structure corresponding to the container recorded in the system kernel. When other processes start in the container subsequently, the system kernel no longer transmits the process ID and namespace identifier to the user-space process. This reduces the frequency of process event transmission between the system kernel and user-space programs, improves the execution efficiency of kernel code and user-space code, and reduces memory consumption. In one embodiment, the method further includes: if a process starts for the first time in the target container, then the step of determining the namespace to which the target container belongs is executed.
[0070] Since the mapping relationship can be determined by any process event that occurs in the container, in one implementation, the method further includes: during the test, transmitting the process ID and namespace identifier of any process in the target container to the user-mode process, so that the user-mode process can determine the container identifier of the target container based on the process ID and construct the mapping relationship between the container identifier and the namespace identifier.
[0071] In one implementation, upon completion of the test, the data structure is transmitted to the user-space process. This allows the user-space process to collect system call information from the target container based on the mapping relationship and the data structure, thus obtaining the collection results. Since the mapping relationship between container identifiers and space identifiers determines the data structure corresponding to the container recorded in the system kernel, and this data structure records all system calls occurring during container testing, collecting all system calls in the data structure yields the container's system call whitelist. This eliminates the need to aggregate system calls from the perspective of each process within the container, thereby improving efficiency. It should be noted that eBPF technology can be used to collect container system calls within the kernel. Pre-written functional code can be mounted into the kernel using eBPF technology to collect system calls during container testing. For example, a control component (corresponding to the eBPF controller component in the following embodiments) can be designed based on eBPF technology to record system calls for a specified container during its testing process and generate a corresponding system call whitelist upon completion of the test.
[0072] After obtaining the collection results, the process also includes synchronizing the collection results to other nodes in the cloud system. The current cloud system may include numerous server nodes, and the same container may run on different nodes due to load balancing or other reasons. Therefore, after obtaining the collection results of a container's system call information (i.e., the container's system call whitelist), the collection results are synchronized to other nodes in the cloud system so that each node can run the container based on the collection results.
[0073] In one implementation, before recording the corresponding system call information into the data structure corresponding to the namespace, the method further includes: determining whether a data structure exists in the system kernel; if it exists, then executing the step of recording the corresponding system call information into the data structure corresponding to the namespace; otherwise, after creating the data structure in the system kernel, executing the step of recording the corresponding system call information into the data structure corresponding to the namespace.
[0074] Since test containers comprehensively test all their functionalities, all system calls required by the container will occur during the test. Therefore, when testing a container, determining the namespace of the target container and recording the corresponding system call information of the system calls initiated by the target container during the test into the container's namespace data structure allows for the aggregation and recording of all system call information for the container. This approach not only completes the container testing but also yields the container's system call whitelist. Therefore, there is no need to specifically run the container to determine its system call whitelist, and the entire process is automated, technically simple, and allows for rapid determination of the container's system call whitelist. Furthermore, since containers are generally comprehensively tested, the system call whitelist ultimately determined through the testing process is relatively complete and less prone to omissions, thus eliminating the need for frequent updates to the container's system call whitelist.
[0075] System calls refer to requests from user-space programs to the operating system kernel for services requiring higher privileges. System calls provide the interface between user programs and the operating system. A system call whitelist is a security configuration file used to restrict system calls made by containers and processes, allowing for functions such as alerting, blocking, and allowing specific system calls. A container is a form of operating system virtualization that can be used to run small microservices, software processes, or the entire contents of a large application. A container contains all the necessary executables, binaries, libraries, and configuration files.
[0076] Furthermore, in this embodiment, different containers are distinguished by their namespaces in the system kernel of the node. This distinguishes the data structures used to record system call information for different containers. Therefore, there is no need to distinguish or pay attention to different processes in the containers, and there is no need for the system kernel and user-mode programs to frequently pass process events in the containers. This can improve the execution efficiency of kernel code and user-mode code and reduce memory consumption.
[0077] See Figure 2 As shown in the embodiments of this application, another system call processing method is disclosed, which is applied to any node in a cloud system, including:
[0078] S201. Obtain the system call whitelist of the target container.
[0079] The system call whitelist is obtained based on the data structure determined in other embodiments of this document. For example, a node transmits the data structure corresponding to the target container in its own system kernel to its user-space process. The user-space process then organizes the system call information recorded in the data structure based on the mapping relationship between the container identifier and namespace identifier of the target container, thus obtaining the system call whitelist for the target container. The newly obtained system call whitelist is stored in a database, generating an update message for the system call whitelist. Each node in the cloud system listens to this database. If it detects an update message for the system call whitelist of its own container, it retrieves the whitelist. After the system call whitelist of a container is stored in the database, it can also be manually modified. This manual modification also generates an update message for the system call whitelist, allowing the node to read the latest system call whitelist from the database based on the update message. In one implementation, if a node detects an update message for the system call whitelist in the database, it reads the latest system call whitelist from the database and replaces the original system call whitelist with the latest one. Manual modification of the whitelist stored in the database can be done for example, when a technician discovers an error in a system call information item in the whitelist and modifies or deletes it.
[0080] S202. Based on the system call whitelist and the target container's operating mode, process the system calls during the target container's operation.
[0081] In one implementation, system calls during the operation of the target container are processed according to a system call whitelist and the target container's operating mode. This includes: if the target container's operating mode is monitoring mode, issuing an anomaly alert for the current system call when it is not recorded in the system call whitelist; if the target container's operating mode is protection mode, intercepting the current system call when it is not recorded in the system call whitelist; or, when a system call not recorded in the system call whitelist occurs during the target container's operation, assessing the risk level of the current system call, and issuing an anomaly alert, intercepting, or allowing the current system call based on the risk level. Therefore, system calls not recorded in the system call whitelist are considered abnormal system calls, and thus require alerting and / or interception.
[0082] The switching between monitoring and protection modes can be based on user commands or preset conditions to allow the container to automatically switch modes. In protection mode, abnormal system calls can be assessed for their risk level, and then the appropriate handling method can be determined based on the assessment results. For example, if the risk level is high, the current system call is blocked; if the risk level is medium, an abnormal alarm is issued for the current system call; if the risk level is low, the current system call is allowed and tracked.
[0083] It should be noted that some system calls occur during container startup, but these system calls generally do not pose vulnerabilities. Therefore, system calls during container startup do not need to be recorded in the system call whitelist. Consequently, the step of detecting container system calls based on the system call whitelist should naturally be performed after the container starts. In one implementation, before obtaining the target container's system call whitelist, the steps include: waiting for a preset time after receiving the target container's startup command; if the wait times out, then obtaining the target container's system call whitelist; and processing system calls during the target container's operation based on the system call whitelist and the target container's running mode. Waiting for a preset time after receiving the target container's startup command allows sufficient time for container startup. The preset time is based on the typical startup time required for a container and can be flexibly adjusted according to actual needs. Not recording system calls during container startup in the system call whitelist reduces the amount of data in the whitelist, facilitating subsequent whitelist retrieval and improving detection efficiency to some extent.
[0084] In one implementation, if the image, namespace, and business tag of the newly created container are all the same as those of the target container, then it is determined that the newly created container and the target container are containers of the same type. After creating a container of the same type as the target container, the system call whitelist is used as the system call whitelist of the newly created container. This enables the reuse of the whitelist without the need for repeated recording and collection.
[0085] In one implementation, after processing the system calls during the operation of the target container according to the system call whitelist and the target container's operating mode, the method further includes: synchronizing the corresponding processing results to other nodes in the cloud system so that other nodes can also analyze and evaluate the container system calls based on these processing results.
[0086] As can be seen, any node in the cloud system can detect the system calls of the corresponding container within itself based on the container's system call whitelist. For example, it can determine whether the system calls of each process in the container on the current node are consistent with the system call information recorded in the whitelist. If they are inconsistent, an alarm is triggered; if they are consistent, corresponding prompts are output. If they are inconsistent, it can be considered that there is an attack anomaly. At this time, further analysis of the operation behavior of the corresponding process, the files operated on, etc., can be performed to locate and resolve the problem in a timely manner.
[0087] In one embodiment, this embodiment can be implemented using eBPF technology. Relevant functional code written using eBPF technology is used to detect container system calls. For example, a control component (corresponding to the eBPF controller component in the following embodiment) is designed based on eBPF technology. When the container is in monitoring mode, the control component uses a whitelist to monitor and alert on abnormal system calls initiated by the container; when the container is in protection mode, the control component uses the whitelist to alert and intercept system calls initiated by the container. It should be noted that detecting abnormal behavior in container system calls can detect system calls prior to an attack, making security protection more granular and timely. This helps to identify attack behavior before an attack occurs. Furthermore, this embodiment alerts and intercepts abnormal system calls, thus enabling alerts and interception of attacks before they occur, thereby improving system security and protection capabilities.
[0088] The following embodiments further illustrate this application using a container application as an example. To implement this embodiment, the following components need to be designed: an eBPF controller component, a profile controller component, a webhook controller component, and a seccompagent component, and installed on each node in the cluster. Please refer to [link to relevant documentation]. Figure 3 The profile controller monitors the container status within a node. When a container is in learning mode, it sends a system call whitelist learning task to the eBPF controller; when a container is in monitoring mode, it sends a system call anomaly monitoring task to the seccomp agent; and when a container is in protection mode, it sends a system call anomaly interception task to the seccomp agent to alert and intercept abnormal system calls for containers that have already mounted the system call whitelist. The eBPF controller component is responsible for recording system calls for specified containers. The webhook controller component is responsible for mounting the system call whitelist to the corresponding containers.
[0089] Please see Figure 3 The implementation process of the learning model includes:
[0090] 1. When a container test begins, the user sends a request to learn the system call whitelist for that container.
[0091] 2. After receiving the learning request, the profile controller creates a recording object and adds a recording tag to the container.
[0092] 3. The eBPF controller listens to the recording object and associates it with the aforementioned container. It then sends a recording request to the eBPF agent through the built-in gRPC client of the eBPF controller, and begins to collect system calls generated by the container.
[0093] 4. The learning mode ends when the container test stops. At this point, the list of collected system call information is stored in the kernel's ebpf map, and is retrieved from the ebpf map via the container's mntns when the collection ends.
[0094] If a user issues a request to end learning for the container, the profile controller receives the request, modifies the status of the previously created recording object to "Ended," and adds a "End Recording" tag to the container. The eBPF controller, upon detecting this status change, stops recording, retrieves the corresponding recording object from the kernel eBPF map, and writes the system call whitelist to each node in the cluster as a JSON file.
[0095] Please see Figure 4 In a single node, the process of recording system calls in learning mode includes:
[0096] 1. Every time a container makes a system call request to the Linux kernel, the BPF program will attach an execution point through the corresponding program to record the information of the system call at that time, and store the information in the BPF Map corresponding to the container.
[0097] 2. The container loads the eBPF object file (the file to which the eBPF controller belongs) into the Linux kernel and turns it into a BPF program;
[0098] 3. The bpf program attaches to the Linux kernel through program attachment points to store the system call list corresponding to mntns.
[0099] 4. When a new mntns appears in the kernel, a PID event corresponding to the container of the new mntns is sent to user space, allowing user space to determine the container corresponding to the new mntns through this PID event. When other PID events appear in that container, the corresponding EBPF map in the kernel is updated directly, without needing to send PID events to user space again. This reduces the number of PID events sent, improves the execution efficiency of kernel and user-space code, and reduces memory consumption.
[0100] After receiving the PID event sent by the kernel, the user space will filter through the containers in the cluster to find the container corresponding to the mntns carried by the PID event. That is, the user space finds the corresponding container ID through the PID information in the PID event to identify the corresponding container, and then maps the mntns information in the PID event to the container ID. This mapping relationship is stored in the user space's sync map.
[0101] Please see Figure 3 In both monitoring and protection modes, taking the creation of a new container as an example, the implementation process includes:
[0102] 1. Create a container that needs to mount the aforementioned system call whitelist. The webhook controller will match the newly created container with the aforementioned system call whitelist. If the match is successful, the aforementioned system call whitelist will be mounted to the newly created container.
[0103] When the Profile controller receives a successful completion response from the eBPF controller, it creates a binding object for the system call whitelist. This binding is used by the webhook controller to handle bindings to the system call whitelist of other containers. For example, if a new container needs to attach the aforementioned system call whitelist, the webhook controller will match the new container with the binding object. If a match is found, the system call whitelist will be attached to the new container. The binding object includes the container image, namespace, and business tag.
[0104] 2. The seccomp agent listens for whitelist mount events through the container's file descriptors. Then, the seccomp agent issues alerts / intercepts based on the container's current mode (monitoring or protection) until the container's lifecycle ends. System calls not recorded in the system call whitelist are considered abnormal system calls. In monitoring mode, only alerts are issued for abnormal system calls generated within the container. In protection mode, both alerts and interceptions are performed for abnormal system calls generated within the container.
[0105] Once a container has a system call whitelist attached, the seccomp agent listens for this event through the container's file descriptor. The seccomp agent first determines if the container is ready. If ready, it delays for 3 minutes before using the system call whitelist to alert for abnormal system calls. The delay time is configurable. The purpose of the delay is to achieve optimal defense at the system call level, utilizing the system call whitelist only during container runtime. This is because the number of system calls during container runtime is minimal, while the total number of system calls during container startup and runtime is significant. Furthermore, system calls during container startup are generally not vulnerable to attacks; therefore, a delay is set to ensure that protection using the system call whitelist is only applied during container runtime.
[0106] Please see Figure 5 The SecComp agent stores abnormal system calls in its cache and updates the cached data to the Consul database (a key-value database) every 3 minutes (the interval is configurable). Correspondingly, upon detecting the cached data being added to the database, the profile controller writes the newly added data to its own cache and periodically synchronizes its cached information to its replicas on other nodes to ensure system call alerts are distributed across all nodes. When a user needs to view alert information, the profile controller returns the cached alert information to the user. The SecComp agent also monitors for updates to the whitelist in the Consul database. Upon detecting an update, it reads the latest whitelist into its memory for use in security protection.
[0107] As can be seen, this embodiment sets up three phases for the container: a learning phase, a monitoring phase, and a protection phase. In the learning phase, automated test cases trigger system calls to the container, and eBPF technology is used to obtain the container's corresponding system call whitelist. In the monitoring phase, when an abnormal system call occurs in the container, an alert is issued for that abnormal system call and its calling file. In the protection phase, when an abnormal system call occurs in the container, it is intercepted, causing the call to fail. The generation of the system call whitelist is integrated into the testing phase of the container application, allowing for sufficient triggering of container system calls through the testing process, ensuring the completeness of the collected container system call whitelist. eBPF is a highly flexible and efficient virtual machine-like component in the Linux kernel, capable of safely executing bytecode at many kernel hook points.
[0108] This embodiment uses eBPF technology, mounting pre-written eBPF C code at the kernel static mount point to collect the system call list corresponding to each container. Since each container is generated on each node and has a unique mntns, the eBPF C code establishes the system call list corresponding to the mntns in the kernel and stores this mapping in the eBPF map. The mapping between containers and their mntns is established in user space. After obtaining the system call list corresponding to the container in user space, a system call whitelist is generated. The system call whitelist is implemented through the eBPF controller component. The eBPF controller generates the corresponding system call whitelist based on the learned system call list and persists the system call whitelist to disk on each node of the cluster.
[0109] This embodiment uses SeccompNotify technology to first identify whether the container is running. If the container is starting up, the seccomp agent will wait until the container is running before alerting / intercepting abnormal system calls. When an abnormal system call occurs in the container, if the container is in monitoring mode, the seccomp agent will alert for the abnormal system call; if the container is in protection mode, the seccomp agent will intercept the abnormal system call. This can protect the system at the system call level, providing finer-grained and timely protection, and can identify and intercept attacks before they occur. System call level protection has higher sensitivity and finer-grained detection. SeccompNotify is a system call filtering method. The SeccompNotify mechanism delegates the decision-making of system calls to the user-space process, and the decision result is returned to the kernel through a file descriptor.
[0110] This embodiment enables comprehensive control over container system calls, including: learning the container's system call list during the learning phase, issuing alerts for abnormal system calls during the monitoring phase, and intercepting abnormal system calls during the protection phase. Throughout the process, relevant personnel can manually change the container mode without requiring in-depth knowledge of system calls, significantly lowering the barrier to system call protection. The automated generation of the system call whitelist improves efficiency. Compared to manually collecting container system calls, automated collection greatly enhances the learning efficiency of system calls, lowers the protection barrier, and ensures a complete whitelist, guaranteeing that all system calls generated by the container during the learning phase are collected without omission. Furthermore, automated monitoring of abnormal system calls improves protection efficiency and effectiveness. The abnormal system call alerting / interception function implemented through SeccompNotify can efficiently handle various aspects of abnormal system calls, allowing for alerting only or performing secondary judgments after tiered processing to determine whether to allow or block, providing diverse handling options for abnormal system calls.
[0111] Furthermore, this embodiment does not affect the normal operation of services within the container. As long as all the interfaces required by the services are run during the learning phase, a low false positive and high detection rate can be guaranteed during the monitoring and alarm phases. Ensuring the normal operation of services is the foundation of system call protection. Through eBPF technology, all system calls of the container can be collected, thereby ensuring that system calls do not affect the normal operation of services. Moreover, this embodiment does not collect system calls during container startup, which reduces the amount of data in the system call whitelist and thus improves the efficiency of system call protection.
[0112] Managing system security at the system call level provides finer-grained protection, allowing for alerts and interception before attacks even begin. This is more effective against 0-day and 1-day vulnerabilities because system call-level protection is harder to bypass when facing unknown attack threats, thus offering stronger defense. A 0-day vulnerability is one that has been discovered (but may not be publicly disclosed) but for which no official patch has been released. In information security terms, a 0-day vulnerability is one that is known or publicly disclosed by the system vendor before they are aware of it and release a patch. A 1-day vulnerability is one that has just been announced but for which no attack examples have been found yet; it is typically announced just one day ago. While not as powerful as a 0-day vulnerability, it can still compromise a server if exploited.
[0113] As can be seen, the entire process of generating the system call whitelist in this embodiment requires virtually no human intervention; the entire process is automated, improving the efficiency of system call whitelist generation. Using eBPF technology to directly collect container system calls at the Linux kernel level ensures the integrity of the container system call whitelist. This embodiment is designed for cloud-native scenarios and is well-suited for cloud-native applications. It only requires tagging the cloud-native applications that need seccomp hardening, generating the system call whitelist during integration testing, and then mounting the system call whitelist to the cloud-native applications in the production environment to complete seccomp hardening. When a container generates an abnormal system call, the seccomp agent will issue an alert or intercept it, achieving secure protection of system calls throughout the container's runtime. seccomp (secure computing) is a security module introduced in Linux kernel version 2.6.12, primarily used to restrict the system calls available to a specific process.
[0114] The following describes a system call processing device provided in an embodiment of this application. The system call processing device described below can be referred to in conjunction with other embodiments.
[0115] See Figure 6 As shown in the figure, this application discloses a system call processing device, applied to the system kernel of any node in a cloud system, including:
[0116] Module 601 is used to determine the namespace to which the target container belongs when testing the target container.
[0117] The recording module 602 is used to record the corresponding system call information to the data structure corresponding to the namespace if the target container initiates a system call during the test.
[0118] In one implementation, the determining module is specifically used for:
[0119] Locate the file mount directory of the target container;
[0120] The namespace is determined based on the file mount directory.
[0121] In one implementation, it further includes:
[0122] The execution module is used to perform steps to determine the namespace to which the target container belongs if a process is started for the first time in the target container.
[0123] In one implementation, it further includes:
[0124] The transmission module is used to transmit the process ID and namespace identifier of any process in the target container to the user-space process during the test, so that the user-space process can determine the container identifier of the target container based on the process ID and build a mapping relationship between the container identifier and the namespace identifier.
[0125] In one implementation, it further includes:
[0126] The generation module is used to transfer the data structure to the user-space process when the test ends, so that the user-space process can collect the system call information of the target container based on the mapping relationship and the data structure to obtain the collection results.
[0127] In one implementation, it further includes:
[0128] The synchronization module is used to synchronize the collected results to other nodes in the cloud system after the results are obtained.
[0129] In one implementation, it further includes:
[0130] The judgment module is used to determine whether the data structure exists in the system kernel. If it exists, the module executes the step of recording the corresponding system call information into the data structure corresponding to the namespace. Otherwise, after creating the data structure in the system kernel, the module executes the step of recording the corresponding system call information into the data structure corresponding to the namespace.
[0131] For more detailed information on the working process of each module and unit in this embodiment, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0132] As can be seen, this embodiment provides a system call processing device that can quickly determine the system call whitelist of a container.
[0133] The following describes another system call processing apparatus provided in the embodiments of this application. The system call processing apparatus described below can be referred to in conjunction with other embodiments.
[0134] See Figure 7 As shown in the figure, this application discloses a system call processing device, which is applied to any node in a cloud system, including:
[0135] Module 701 is used to obtain the system call whitelist of the target container; the system call whitelist is obtained based on any of the data structures mentioned above.
[0136] Processing module 702 is used to process system calls during the operation of the target container based on the system call whitelist and the target container's operating mode.
[0137] In one implementation, the processing module is specifically used for:
[0138] If the target container is running in monitoring mode, an abnormal alarm will be issued for the current system call if a system call not recorded in the system call whitelist occurs during the operation of the target container.
[0139] If the target container is running in protected mode, then when a system call not recorded in the system call whitelist occurs during the operation of the target container, the current system call will be intercepted; or when a system call not recorded in the system call whitelist occurs during the operation of the target container, the danger level of the current system call will be assessed, and an abnormal alarm, interception, or allowment will be issued for the current system call based on the danger level.
[0140] In one implementation, it further includes:
[0141] If an update message for the system call whitelist is detected in the database, the latest system call whitelist is read from the database and replaced with the latest system call whitelist.
[0142] In one implementation, it further includes:
[0143] The waiting module is used to wait for a preset time after receiving the start command of the target container; if the wait times out, it will execute the steps of obtaining the system call whitelist of the target container; and handle the system calls during the operation of the target container according to the system call whitelist and the running mode of the target container.
[0144] In one implementation, it further includes:
[0145] The configuration module is used to use the system call whitelist as the system call whitelist for newly created containers that are of the same type as the target container.
[0146] In one implementation, if the image, namespace, and business tag of the newly created container are identical to those of the target container, then the newly created container and the target container belong to the same type of container.
[0147] In one implementation, after processing the system calls during the operation of the target container according to the system call whitelist and the target container's operating mode, the process further includes: synchronizing the corresponding processing results to other nodes in the cloud system.
[0148] For more detailed information on the working process of each module and unit in this embodiment, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0149] As can be seen, this embodiment provides a system call processing device that detects abnormal behavior of container system calls, making the granularity of security protection more detailed and timely, and helping to identify attack behavior before an attack occurs.
[0150] The following describes an electronic device provided by an embodiment of this application. The electronic device described below can be referred to in conjunction with other embodiments.
[0151] See Figure 8 As shown in the figure, an embodiment of this application discloses an electronic device, including:
[0152] Memory 801 is used to store computer programs;
[0153] Processor 802 is configured to execute the computer program to implement the method disclosed in any of the above embodiments.
[0154] Please refer to Figure 9 , Figure 9 This is a schematic diagram of another electronic device provided in this embodiment. This electronic device can vary significantly due to differences in configuration or performance. It may include one or more central processing units (CPUs) 322 (e.g., one or more processors) and a memory 332, and one or more storage media 330 (e.g., one or more mass storage devices) for storing application programs 342 or data 344. The memory 332 and storage media 330 can be temporary or persistent storage. The program stored in the storage media 330 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the data processing device. Furthermore, the central processing unit 322 may be configured to communicate with the storage media 330 and execute the series of instruction operations in the storage media 330 on the electronic device 301.
[0155] Electronic device 301 may also include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input / output interfaces 358, and / or one or more operating systems 341. Examples include Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0156] exist Figure 9 In this context, application 342 may be a program that executes a system call handling method, and data 344 may be data required or generated by executing the system call handling method.
[0157] The steps in the system call handling method described above can be implemented by the structure of the electronic device.
[0158] The following describes a readable storage medium provided in an embodiment of this application. The readable storage medium described below can be referred to in conjunction with other embodiments.
[0159] A readable storage medium is provided for storing a computer program, wherein the computer program, when executed by a processor, implements the method disclosed in the foregoing embodiments. Specific steps of the method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0160] The terms “first,” “second,” “third,” “fourth,” etc., used in this application (if applicable) are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, or apparatus that includes a series of steps or units is not necessarily limited to those explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, or apparatus.
[0161] It should be noted that the use of terms such as "first" and "second" in this application is for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of those features. Furthermore, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, such a combination of technical solutions should be considered non-existent and not within the scope of protection claimed in this application.
[0162] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0163] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of readable storage medium known in the art.
[0164] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A system call processing method, characterized in that, The system kernel used in any node of a cloud system includes: When testing a target container, determine the namespace to which the target container belongs; If the target container initiates a system call during the test, the corresponding system call information will be recorded in the data structure corresponding to the namespace. Specifically, different containers are distinguished by their namespaces, and different data structures for recording system call information are distinguished for each container. Different processes within the same container have the same namespace. When a process is first started in the target container, the namespace to which the target container belongs is determined. The process ID of the first started process and the space identifier of the namespace to which the container belongs are transmitted to the user-space process of the current node, so that the user-space process can determine the container identifier of the container based on the process ID and construct a mapping relationship between the container identifier and the space identifier.
2. The system call processing method according to claim 1, characterized in that, Determining the namespace to which the target container belongs includes: Query the file mount directory of the target container; The namespace is determined based on the file mount directory.
3. A system call processing method, characterized in that, Applied to any node in the cloud system, including: Obtain the system call whitelist of the target container; the system call whitelist is obtained based on the data structure described in claim 1 or 2. Based on the system call whitelist and the target container's operating mode, process the system calls made during the target container's operation.
4. The system call processing method according to claim 3, characterized in that, The step of processing system calls during the execution of the target container based on the system call whitelist and the target container's operating mode includes: If the target container is running in monitoring mode, then when a system call not recorded in the system call whitelist occurs during the operation of the target container, an abnormal alarm will be issued for the current system call. If the target container is in protected mode, then when a system call not recorded in the system call whitelist occurs during the operation of the target container, the current system call is intercepted; or when a system call not recorded in the system call whitelist occurs during the operation of the target container, the danger level of the current system call is assessed, and an abnormal alarm, interception, or release is issued for the current system call based on the danger level.
5. The system call processing method according to claim 3, characterized in that, Also includes: After creating a new container of the same type as the target container, use the system call whitelist as the system call whitelist for the new container.
6. The system call processing method according to claim 3, characterized in that, Also includes: If an update message for the system call whitelist is detected in the database, the latest system call whitelist is read from the database and replaced with the latest system call whitelist.
7. A system call processing device, characterized in that, The system kernel used in any node of a cloud system includes: The determination module is used to determine the namespace to which the target container belongs when testing the target container; The recording module is used to record the corresponding system call information to the data structure corresponding to the namespace if the target container initiates a system call during the test. Different containers are distinguished by their namespaces, and different data structures for recording system call information are used for each container. Different processes within the same container share the same namespace. When a process starts for the first time in the target container, the namespace to which the target container belongs is determined. The process ID of the first started process and the space identifier of the namespace to which the container belongs are transmitted to the user-space process of the current node, so that the user-space process can determine the container identifier based on the process ID and construct a mapping relationship between the container identifier and the space identifier.
8. A system call processing device, characterized in that, Applied to any node in the cloud system, including: An acquisition module is used to acquire the system call whitelist of the target container; the system call whitelist is obtained based on the data structure described in claim 1 or 2. The processing module is used to process system calls during the operation of the target container based on the system call whitelist and the target container's operating mode.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the method as described in any one of claims 1 to 6.
10. A readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Recorder, recording method and component, detection method and component, and cloud system
CN115509862A
