A method and device for virtual machine anti-attack protection combining software and hardware
In the cloud scenario, the chip network card subsystem hardware is used to check the legality of the descriptor and independently write back the wrong descriptor, which solves the problem of the network card being vulnerable to attacks in the cloud scenario, improves the network card performance and network stability, and reduces the software cost. Overhead and virtual function level reset frequency.
Patent Information
- Application Number
- CN202311739325.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-15
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2043-12-15
AI Technical Summary
In cloud scenarios, network cards that support the SRIOV feature are vulnerable to malicious attacks due to the shared DMA hardware engine between queues, resulting in insufficient network robustness and low network card transceiver efficiency due to traditional software protection measures.
Through a virtual machine anti-attack protection method that combines software and hardware, the chip network card subsystem hardware is used to automatically check the legitimacy of the descriptor, and write back the wrong descriptor in an independent recycling channel to generate interrupts, reduce software overhead, and achieve rapid resource recycling.
Improved network card performance, enhanced network robustness, reduced software overhead and virtual function level reset frequency, prevented error spread, and improved network stability.
Smart Images

Figure CN117729022B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of network security, and in particular relates to a virtual machine anti-attack protection method and device combining software and hardware. Background Art
[0002] NICs that support the Single Root Input Output Virtualization (SRIOV) feature can virtualize multiple virtual function (VF) devices and pass them through to virtual machines to solve NIC performance issues in cloud scenarios. In order to ensure the customer's service level agreement (SLA), cloud scenarios have extremely high requirements for the security and stability of devices. Cloud service providers will take a variety of protection measures to resist malicious attacks on pass-through devices.
[0003] Although NICs that support the SRIOV feature allocate a separate hardware queue for each VF, there is a shared DMA hardware engine between the queues. Malicious attackers can indirectly attack the DMA engine through the hardware queue, affecting other users and even paralyzing the cloud service. Traditional protection measures are software-based solutions that do not expose real hardware queue resources to virtual machines (VMs). Instead, they use software simulation to verify the data sent by VMs in the hypervisor to prevent hacker attacks. However, due to the introduction of software overhead and the fact that the verification check of descriptor data occurs on the data channel, the NIC transceiver efficiency is extremely low.
[0004] There are a large number of descriptor fields that support hardware offloading. When a competitor's network card encounters an error in the descriptor content, it is easy for the error to spread, or even paralyze the entire network, resulting in insufficient network robustness. In addition, the existing software function of emptying the descriptor can only force the head pointer and the tail pointer to be equal, which cannot achieve the purpose of rapid resource recovery. Summary of the invention
[0005] The purpose of the present invention is to provide a virtual machine anti-attack protection method and device combining software and hardware, aiming to solve the problem of low receiving and sending efficiency caused by large software overhead when a network card implements anti-attack protection.
[0006] According to a first aspect of the present invention, a virtual machine anti-attack protection method combining software and hardware is provided, comprising:
[0007] Receive and send network message requests, write the pending descriptors and message data into the queue descriptor space through the virtual machine management software, and send doorbell commands to the chip network card subsystem;
[0008] When the chip network card subsystem receives the doorbell command, it reads the to-be-processed descriptor from the queue descriptor space and performs a validity check;
[0009] In response to a failure of the legality check, using the chip network card subsystem to write back an error descriptor in an independent recycling channel, generating an error interrupt and reporting the error interrupt to the virtual machine management software through the virtual machine;
[0010] According to the error descriptor, the chip network card subsystem is instructed to reclaim resources of the queue descriptor space.
[0011] Preferably, the step of writing the to-be-processed descriptor and the message data into the queue descriptor space through the virtual machine management software and issuing a doorbell command to the chip network card subsystem further comprises:
[0012] Using the virtual machine management software to write the descriptor into the queue descriptor space through DMA, and writing the message data into the corresponding address space in the descriptor;
[0013] Write operations are performed on the corresponding register space, and then a doorbell command is issued to notify the chip network card subsystem that there are new tasks to be processed.
[0014] Preferably, the reading of the to-be-processed descriptor from the queue descriptor space and performing a validity check further comprises:
[0015] The read descriptor is globally segmented, the legitimacy of the descriptor is confirmed, the total length indicated by the descriptor and the actual length of the message are checked, and the descriptor unloading command and the number of descriptors are checked.
[0016] Preferably, after the legality check, the method further includes:
[0017] In response to passing the legality check, the chip network card subsystem is used to read the message data, and after the reading is completed, a write-back descriptor is generated, and an interrupt is generated and reported to the virtual machine management software.
[0018] Preferably, the instructing the chip network card subsystem to reclaim resources of the queue descriptor space further comprises:
[0019] The virtual machine management software is used to generate a drain command to instruct the chip network card subsystem to generate a write-back descriptor and report the service interruption to achieve resource recovery.
[0020] According to a second aspect of the present invention, there is provided a virtual machine anti-attack protection device combining software and hardware, comprising:
[0021] A software writing unit, used to receive a request to send a network message, write the descriptor to be processed and the message data into the queue descriptor space, and send a doorbell command to the chip network card subsystem;
[0022] A hardware checking unit, configured to read the to-be-processed descriptor from the queue descriptor space and perform a validity check when a doorbell command is received;
[0023] A hardware write-back unit, configured to, in response to a failure of the legality check, write back an error descriptor in an independent recycling channel, generate an error interrupt, and report the error interrupt to the virtual machine management software through the virtual machine;
[0024] The software recovery unit is used to instruct the chip network card subsystem to recover resources of the queue descriptor space according to the error descriptor.
[0025] Compared with the prior art, the technical solution of the present invention has the following advantages:
[0026] First, this method adopts direct virtualization and implements the reading and writing of descriptors and data through DMA, which reduces the delay caused by the software middle layer's data inspection and storage forwarding and improves the performance of the network card.
[0027] Secondly, the legitimacy check of queue descriptor information is completed through the chip network card subsystem structure. When a descriptor error is found, the descriptor is written back through an independent recycling channel to prevent the spread of errors and enhance the robustness of the network. At the same time, it avoids relying on software for legitimacy checks and significantly reduces software overhead.
[0028] In addition, by sending a drain command through software, the descriptor can be quickly written back to reclaim storage space, reducing the frequency of virtual function level reset (VFLR) use, and quickly realizing the switching of queue sending services and resource recovery.
[0029] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures and processes indicated in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. It is obvious that the drawings described below are certain embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0031] Figure 1 It is an overall flow chart of the virtual machine anti-attack protection method combining software and hardware according to the present invention.
[0032] Figure 2It is a schematic diagram of a queue structure for processing messages according to the present invention.
[0033] Figure 3 It is a detailed flow chart of the virtual machine anti-attack protection method according to the present invention. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0035] Based on the above analysis, the present invention proposes a virtual machine anti-attack protection method and device that combines software and hardware. It adopts a mechanism based on chip protection hardware queue. The chip network card subsystem hardware automatically checks the legitimacy of user input data, encodes and classifies error types, provides an independent recovery channel, reduces the impact of virtual machine management software on hardware processing, does not affect user experience while achieving network security, improves network robustness, and reduces CPU occupancy.
[0036] See also Figure 1 The virtual machine anti-attack protection method provided by the present invention combines software and hardware and includes:
[0037] Step 101: Receive a request to send a network message, write the descriptor to be processed and the message data into the queue descriptor space through the virtual machine management software, and send a doorbell command to the chip network card subsystem.
[0038] Specifically, the virtual machine management software writes the descriptor into the queue descriptor space through DMA, and writes the message data into the corresponding address space in the descriptor; writes the corresponding register space, and then issues a doorbell command to notify the chip network card subsystem hardware that there is a new task to be processed.
[0039] The queue structure of the network card chip processing messages is as follows Figure 2 As shown, each queue includes configurations such as base address, length, and descriptor size; the virtual machine management software fills the queue with the prepared data. Figure 2 In the example, it is represented as one or more pending descriptors M, M+1 and M+2, which represent the message information to be sent; the space not used by the virtual machine management software is in Figure 2 In the figure, it is represented as descriptors O to N. Through the interaction between software and hardware, the descriptor space is recycled.
[0040] Step 102: When the chip network card subsystem receives the doorbell command, it reads the to-be-processed descriptor from the queue descriptor space and performs a validity check.
[0041] See also Figure 3 After receiving the doorbell command, the chip NIC subsystem hardware reads the descriptor to be processed from the main memory through the data bus. The chip NIC subsystem hardware performs global segment analysis on the read descriptor to confirm the legitimacy of the descriptor, including checking the total length indicated by the descriptor and the actual length of the message, checking the descriptor unloading command, such as checksum unloading, sending message slices, and checking the number of descriptors.
[0042] Step 103: In response to the failure of the validity check, the chip network card subsystem is used to write back the error descriptor in an independent recycling channel, an error interrupt is generated, and the error interrupt is reported to the virtual machine management software through the virtual machine.
[0043] Specifically, the legitimacy check is to check whether the descriptor to be processed is an illegal descriptor through the chip network card subsystem hardware. If the legitimacy check is passed, the message data can be read, and a write-back descriptor is generated after the reading is completed, and an interrupt is generated and reported to the virtual machine management software. If the legitimacy check is not passed, after the chip network card subsystem hardware classifies and encodes the illegal descriptor error, the error descriptor error type and the current error handling method are written back through an independent recycling channel, and the interrupt is reported to the physical function (PF) to which the current virtual machine belongs, and the physical function (PF) forwards the interrupt to the virtual machine management software.
[0044] Step 104: According to the error descriptor, instruct the chip network card subsystem to reclaim resources of the queue descriptor space.
[0045] When the physical function (PF) forwards the interrupt to the virtual machine management software, the write-back descriptor is read, the storage address space is reclaimed, and according to the error type of the error descriptor, it is decided whether to continue to use the current queue.
[0046] In a specific embodiment, if an accidental error occurs, the virtual machine management software determines that the current queue can continue to be used, and the subsequent sent services will not be affected by the previous error. However, if a large number of errors occur, or the descriptor command is not sent and does not need to be processed further, the virtual machine management software can send a drain command to instruct the chip network card subsystem hardware to quickly write back the descriptor, report the service interruption, and realize rapid resource recovery.
[0047] Through the above interactive process, the chip network card subsystem hardware completes the anti-attack protection of the descriptor and realizes the self-recovery function with the help of an independent recycling channel; by providing a software emptying method, the purpose of rapid resource recovery is achieved.
[0048] It can be seen that the virtual machine anti-attack protection method combining software and hardware proposed in the present invention has the following advantages over the prior art:
[0049] First, this method adopts direct virtualization and implements the reading and writing of descriptors and data through DMA, which reduces the delay caused by the software middle layer's data inspection and storage forwarding and improves the performance of the network card.
[0050] Secondly, the legitimacy check of queue descriptor information is completed through the hardware structure of the chip network card subsystem. When a descriptor error is found, the descriptor is written back through an independent recycling channel to prevent the spread of errors and enhance the robustness of the network. At the same time, it avoids relying on software for legitimacy checks and significantly reduces software overhead.
[0051] In addition, by sending a drain command through software, the descriptor can be written back quickly, and the pointers can be made equal by hardware writing back the descriptor space to reclaim the storage space, reducing the frequency of virtual function level reset (VFLR) use, and quickly realizing the switching of queue sending services and resource recovery.
[0052] Accordingly, the present invention provides a virtual machine anti-attack protection device combining software and hardware in a second aspect, comprising:
[0053] A software writing unit, used to receive and send network message requests through the virtual machine management software, write the descriptor to be processed and the message data into the queue descriptor space, and send a doorbell command to the chip network card subsystem hardware;
[0054] A hardware checking unit, configured to read the to-be-processed descriptor from the queue descriptor space and perform a validity check when the chip network card subsystem receives a doorbell command;
[0055] A hardware write-back unit, configured to, in response to a failure of the legality check, write back an error descriptor in an independent recycling channel, generate an error interrupt, and report the error interrupt to the virtual machine management software through the virtual machine;
[0056] The software recovery unit is used to instruct the chip network card subsystem to recover resources of the queue descriptor space according to the error descriptor.
[0057] The above-mentioned device can be implemented by the virtual machine anti-attack protection method combining software and hardware provided in the embodiment of the first aspect above. The specific implementation method can be found in the description of the embodiment of the first aspect, which will not be repeated here.
[0058] It is understood that the queue structures, names and parameters described in the above embodiments are only examples. Those skilled in the art can also easily combine and adjust the structural features of the above embodiments according to the use requirements, and should not limit the concept of the present invention to the specific details of the above examples.
[0059] Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent substitutions for some of the technical features therein; and these modifications or substitutions do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A virtual machine anti-attack protection method combining software and hardware, characterized in that: include: Receive network message sending request, write the pending descriptor and message data into the queue descriptor space through the virtual machine management software, and send the doorbell command to the chip network card subsystem; When the chip network card subsystem receives the doorbell command, it reads the to-be-processed descriptor from the queue descriptor space and performs a validity check; In response to a failure of the legality check, using the chip network card subsystem to write back an error descriptor in an independent recycling channel, generating an error interrupt and reporting the error interrupt to the virtual machine management software through the virtual machine; Instructing the chip network card subsystem to reclaim resources of the queue descriptor space according to the error descriptor; The step of reading the to-be-processed descriptor from the queue descriptor space and performing a validity check further comprises: Perform global segment analysis on the read descriptor to confirm the legitimacy of the descriptor, check the total length indicated by the descriptor and the actual length of the message, and check the descriptor unloading command and the number of descriptors; The instructing the chip network card subsystem to reclaim resources of the queue descriptor space further includes: The virtual machine management software is used to generate a drain command to instruct the chip network card subsystem to generate a write-back descriptor and report the service interruption to achieve resource recovery.
2. The method for virtual machine anti-attack protection combining software and hardware according to claim 1, characterized in that: The method further includes: writing the to-be-processed descriptor and the message data into the queue descriptor space through the virtual machine management software, and sending a doorbell command to the chip network card subsystem. Using the virtual machine management software to write the descriptor into the queue descriptor space through DMA, and writing the message data into the corresponding address space in the descriptor; Write operations are performed on the corresponding register space, and then a doorbell command is issued to notify the chip network card subsystem that there are new tasks to be processed.
3. The virtual machine anti-attack protection method combining software and hardware according to claim 1 is characterized in that: After the legality check, it also includes: In response to passing the legality check, the chip network card subsystem is used to read the message data, and after the reading is completed, a write-back descriptor is generated, and an interrupt is generated and reported to the virtual machine management software.
4. A virtual machine anti-attack protection device combining software and hardware, characterized in that: include: A software writing unit, used to receive a network message sending request through the virtual machine management software, write the to-be-processed descriptor and message data into the queue descriptor space, and send a doorbell command to the chip network card subsystem; A hardware checking unit, configured to read the to-be-processed descriptor from the queue descriptor space and perform a validity check when the chip network card subsystem receives a doorbell command; A hardware write-back unit, configured to respond to a failure of a legality check by writing back an error descriptor in an independent recycling channel, generating an error interrupt, and reporting the error interrupt to a virtual machine management software through a virtual machine; A software recovery unit, used for instructing the chip network card subsystem to recycle resources of the queue descriptor space according to the error descriptor; The hardware inspection unit is further used for: Perform global segment analysis on the read descriptor to confirm the legitimacy of the descriptor, check the total length indicated by the descriptor and the actual length of the message, and check the descriptor unloading command and the number of descriptors; The software recovery unit is further used for: The virtual machine management software is used to generate a drain command to instruct the chip network card subsystem to generate a write-back descriptor and report the service interruption to achieve resource recovery.
5. The virtual machine anti-attack protection device combining software and hardware according to claim 4 is characterized in that: The software writing unit is further used for: Using the virtual machine management software to write the descriptor into the queue descriptor space through DMA, and writing the message data into the corresponding address space in the descriptor; Write operations are performed on the corresponding register space, and then a doorbell command is issued to notify the chip network card subsystem that there are new tasks to be processed.
6. The virtual machine anti-attack protection device combining software and hardware according to claim 4, characterized in that: The hardware inspection unit is further used for: In response to passing the legality check, the chip network card subsystem is used to read the message data, and after the reading is completed, a write-back descriptor is generated, and an interrupt is generated and reported to the virtual machine management software.
