Process communication method and device, electronic equipment and readable storage medium
By allocating physical memory to the process in a trusted execution environment and transferring access rights using SPMP registers, the problem that the operating system isolation mechanism cannot guarantee the security of inter-process communication is solved, and high-security and orderly inter-process communication is achieved.
Patent Information
- Application Number
- CN202411562434.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-11-04
AI Technical Summary
The existing operating system dependency isolation mechanism cannot effectively ensure the security of communication between processes with high security levels and cannot meet the security requirements of communication between processes.
In a trusted execution environment based on physical memory protection, physical memory is allocated to the process, and a double-layer nested composite architecture is implemented through the privileged mode physical memory protection register. Access permissions are transferred during communication through the SPMP register to ensure that only the only ones are available at the same time. A process has access rights.
It improves the security and orderliness of inter-process communication, meets the security needs of inter-process communication, and avoids the unnecessary and malicious modification of shared memory.
Smart Images

Figure CN119065873A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a process communication method, device, electronic device and readable storage medium. Background Art
[0002] With the development of computer technology, users' demand for privacy protection and confidential computing is increasing, which requires the secure isolation of specific software and other processes. Currently, the isolation of low-privilege processes often relies on processes running at a high privilege level.
[0003] However, with the development of software technology, the functions of operating systems are becoming more and more abundant. The kernel code of macro-kernel operating systems represented by Linux has exploded. Due to the complexity of the operating system, its potential risks are increasing. The security mechanism that relies on the operating system for isolation cannot guarantee the security of high-security-level processes, and thus cannot meet the security requirements of communication between different processes. Summary of the Invention
[0004] The purpose of the embodiments of the present invention is to provide a process communication method, apparatus, electronic device, and readable storage medium to meet the security requirements of communication between different processes. The specific technical solution is as follows: In a first aspect of the present invention, a process communication method is provided. The method is applied to a monitoring terminal included in a process communication system, wherein the process communication system further includes at least two processes. The method includes: In response to receiving a communication request from any process, determining a requesting process and a responding process indicated by the communication request; Allocating physical memory for the requesting process as communication memory in a trusted execution environment built based on physical memory protection, and refreshing configuration information in a privileged mode physical memory protection register to first configuration information, wherein the first configuration information is used to indicate that the requesting process has permission to access the communication memory; After the requesting process accesses the communication memory and writes the communication data, refreshing the configuration information in the privileged mode physical memory protection register to second configuration information, so that the responding process reads the communication data in the communication memory and writes the response data, wherein the second configuration information is used to indicate that the access permission of the responding process to the communication memory is allowed; The operation of refreshing the configuration information in the privileged mode physical memory protection register to the first configuration information is performed again, so that the requesting process reads the response data in the communication memory.
[0005] In a second aspect of the present invention, a process communication device is provided. The device is applied to a monitoring terminal included in a process communication system, wherein the process communication system further includes at least two processes. The device includes: A first determining module is configured to, in response to receiving a communication request from any process, determine a requesting process and a responding process indicated by the communication request; A first allocation module is configured to allocate physical memory for the requesting process as communication memory in a trusted execution environment constructed based on physical memory protection, and to refresh configuration information in a privileged mode physical memory protection register to first configuration information, wherein the first configuration information is used to indicate that the access permission of the requesting process to the communication memory is allowed; a refresh module, configured to refresh the configuration information in the privileged mode physical memory protection register to second configuration information after the requesting process accesses the communication memory and writes the communication data, so that the responding process reads the communication data in the communication memory and writes the response data, wherein the second configuration information is used to indicate that the access permission of the responding process to the communication memory is allowed; The execution module is configured to re-execute the operation of refreshing the configuration information in the privileged mode physical memory protection register to the first configuration information, so that the requesting process reads the response data in the communication memory.
[0006] In a third aspect of the present invention, an electronic device is provided, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus; Memory for storing computer programs; The processor is configured to implement the method described in the first aspect above when executing the program stored in the memory.
[0007] In a fourth aspect of the implementation of the present invention, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores instructions that, when executed on a computer, enable the computer to execute the method described in the first aspect above.
[0008] In a fifth aspect of the implementation of the present invention, a computer program product comprising instructions is further provided, which, when executed on a computer, enables the computer to execute the method described in the first aspect above.
[0009] A process communication method provided by an embodiment of the present invention determines the requesting process and the responding process indicated by the communication request in response to receiving a communication request from any process; allocates physical memory to the requesting process in a trusted execution environment constructed based on physical memory protection as communication memory, and refreshes the configuration information in the privileged mode physical memory protection register to first configuration information, wherein the first configuration information is used to characterize that the access right of the requesting process to the communication memory is allowed access; after the requesting process accesses the communication memory to write communication data, the configuration information in the privileged mode physical memory protection register is refreshed to second configuration information, so that the responding process reads the communication data in the communication memory and writes response data, wherein the second configuration information is used to characterize that the access right of the responding process to the communication memory is allowed access; and the operation of refreshing the configuration information in the privileged mode physical memory protection register to the first configuration information is performed again, so that the requesting process reads the response data in the communication memory. In this way, by allocating physical memory to processes that need to communicate with each other in a trusted execution environment, a two-layer nested combination architecture based on PMP and SPMP can be implemented. Physical memory is allocated for process communication through this two-layer nested combination architecture, and the access rights to the allocated communication memory are transferred through the SPMP register during the communication process, so that at the same time, only one requesting process or responding process has access to the communication memory, avoiding unnecessary and malicious modifications to shared memory, improving the security of inter-process communication, meeting the security requirements of communication between different processes, and ensuring the orderliness of communication. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for describing the embodiments or the prior art.
[0011] Figure 1 is a flowchart of a process communication method according to an embodiment of the present invention; Figure 2 1 is a schematic structural diagram of a process communication device according to an embodiment of the present invention; Figure 3 FIG. 4 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0012] The technical solutions in the embodiments of the present invention will be described below with reference to the accompanying drawings in the embodiments of the present invention.
[0013] Figure 1FIG. 1 is a flowchart of a process communication method according to an embodiment of the present invention. The method can be applied to a monitoring terminal included in a process communication system. The process communication system can also include at least two processes, such as Figure 1 As shown, the method includes: Step 101: In response to receiving a communication request from any process, determine the requesting process and the responding process indicated by the communication request.
[0014] Step 102: Allocate physical memory for the requesting process in a trusted execution environment built based on physical memory protection as communication memory, and refresh the configuration information in the privileged mode physical memory protection register to the first configuration information, wherein the first configuration information is used to indicate that the access right of the requesting process to the communication memory is allowed access.
[0015] Step 103: After the requesting process accesses the communication memory and writes the communication data, the configuration information in the privileged mode physical memory protection register is refreshed to the second configuration information, so that the responding process reads the communication data in the communication memory and writes the response data. The second configuration information is used to indicate that the responding process has access rights to the communication memory as allowed access.
[0016] Step 104 : Refresh the configuration information in the privileged mode physical memory protection register to the first configuration information, so that the requesting process reads the response data in the communication memory.
[0017] The process communication system in the embodiments of the present invention can utilize the open-source instruction set architecture (RISC-V). The processes in the embodiments of the present invention can be system software or applications, and can belong to areas with high security requirements and communication needs, such as cloud services or mobile social networks. The embodiments of the present invention do not restrict the specific type of process. For example, the embodiments of the present invention can be applied to multi-terminal communication of confidential programs in cloud scenarios. In cloud scenarios, cloud service providers provide privacy computing services to users. A single user may create multiple confidential computing programs (i.e., processes), which may need to communicate with each other. A single cloud server often runs hundreds or even thousands of confidential computing programs. These numerous confidential computing programs running on the entire cloud server may need to communicate in groups of two, three, or more, acting as various forms of producer-consumer models (request process - response process) to communicate. The monitoring end can be a hardware or software device running at a higher security level, such as a security monitor.
[0018] The communication request is used to instruct communication with another process. The requesting process refers to the process that sends the communication request, and the responding process refers to the other process with which the requesting process needs to communicate. Specifically, the communication request may carry the process identifiers of the requesting process and the responding process. Thus, embodiments of the present invention can identify the requesting process and the responding process based on the process identifiers in the communication request.
[0019] The aforementioned Physical Memory Protection (PMP) is a protection mechanism provided by RISC-V, which can establish a secure enclave using PMP registers. The aforementioned Trusted Execution Environment (TEE) refers to a fully trusted execution environment created using hardware and software and isolated from the operating system. Physical memory can be isolated using PMP registers to construct a TEE. The TEE utilizes a security monitor running at the highest privilege level to establish a secure enclave, preventing unauthorized privileged software such as the operating system, hypervisor, and other untrusted applications from accessing it. This isolation mechanism prevents any attempts to modify application code or tamper with data, effectively protecting against external threats. Specifically, when establishing a trusted execution environment, a contiguous memory allocator (CMA) can be used to allocate a large block of contiguous physical memory to the monitoring end, which is then associated with a set of PMP registers to create a trusted execution environment. Furthermore, in embodiments of the present invention, the monitoring end can manage the allocation and deallocation of this contiguous physical memory through a partner system.
[0020] Furthermore, embodiments of the present invention can allocate physical memory to the requesting process within a trusted execution environment (PE) built on PMP. Specifically, the size and address of the physical memory allocated to the requesting process can be determined based on the memory size of the trusted execution environment and the actual requirements of the communication request, and are not limited in this embodiment of the present invention.
[0021] Privileged Mode Physical Memory Protection (SPMP) provides several privileged mode physical memory protection registers in each central processing unit (CPU) core to restrict memory access rights to specified contiguous physical memory ranges. The privileged mode physical memory protection registers are the registers provided by SPMP, namely, the SPMP registers.
[0022] Furthermore, an embodiment of the present invention can allocate communication memory to the requesting process in the trusted execution environment (i.e., the above-mentioned continuous physical memory) constructed by the monitoring end, and the communication memory can be used as a shared memory for the communication request to transmit relevant data in the process communication. Specifically, after allocating physical memory to the requesting process, the access rights to the communication memory can be configured for the requesting process in the SPMP register to allow access. Specifically, the SPMP register can limit the memory access rights to a specified continuous physical memory interval, and an embodiment of the present invention can refresh the memory address of the communication memory, the process ID (eid) of the requesting process, and the allowed access rights into the SPMP register. Specifically, the above-mentioned refresh operation refers to overwriting the original data, that is, deleting the original data in the SPMP register and writing the first configuration information. Furthermore, the above-mentioned refresh operation can be implemented by a pre-written transfer code or transfer instruction (transfer instruction).
[0023] The above-mentioned access permission refers to readable, writable, and executable. Among them, readable refers to the ability to read content, writable refers to the ability to write content, and executable refers to the ability to run content.
[0024] Furthermore, by refreshing the configuration information in the SPMP register to the first configuration information, the ownership of the communication memory can be set to be exclusive to the requesting process. Accordingly, the requesting process can access the communication memory and write communication data according to actual communication needs. Subsequently, embodiments of the present invention can refresh the configuration information in the SPMP to the second configuration information, transferring ownership of the communication memory from the requesting process to the responding process. This allows the responding process to access the communication memory, read communication data, respond, and write response data.
[0025] Furthermore, the configuration information in the SPMP can be refreshed to the first configuration information again, thereby transferring the ownership of the communication memory from the responding process to the requesting process again, so that the requesting process can read the response data therein by accessing the communication memory.
[0026] The SPMP register in steps 102 to 104 may be an idle SPMP register selected from all SPMP registers to avoid affecting the operation or communication of other processes.
[0027] Furthermore, in step 103, the monitoring end of the embodiment of the present invention may also provide a calling interface for the process. After the requesting process writes communication data to the communication memory, the requesting process may initiate a call request to the monitoring end through the calling interface. Accordingly, upon receiving the call request from the requesting process, the monitoring end refreshes the configuration information in the SPMP register to the second configuration information. The responding process writes response data in a similar manner, which will not be further described here.
[0028] Optionally, in the embodiment of the present invention, after the request process reads the response data in the communication memory, the following steps may be further included: Step 105: Release the communication memory and delete the configuration information in the privileged mode physical memory protection register.
[0029] The release operation can be implemented using a memory destruction instruction (e.g., the destroy instruction). Accordingly, the deletion operation restores the configuration information in the SPMP register to its default or initial value. This step frees up resources on the monitoring end and improves resource utilization.
[0030] To sum up, in an embodiment of the present invention, by responding to a communication request received from any process, the requesting process and the responding process indicated by the communication request are determined; physical memory is allocated to the requesting process in a trusted execution environment constructed based on physical memory protection as communication memory, and the configuration information in the privileged mode physical memory protection register is refreshed to the first configuration information, the first configuration information being used to characterize that the access right of the requesting process to the communication memory is allowed access; after the requesting process accesses the communication memory to write communication data, the configuration information in the privileged mode physical memory protection register is refreshed to the second configuration information, so that the responding process reads the communication data in the communication memory and writes response data, the second configuration information being used to characterize that the access right of the responding process to the communication memory is allowed access; the operation of refreshing the configuration information in the privileged mode physical memory protection register to the first configuration information is performed again, so that the requesting process reads the response data in the communication memory. In this way, by allocating physical memory to processes that need to communicate with each other in a trusted execution environment, a two-layer nested combination architecture based on PMP and SPMP can be implemented. Physical memory is allocated for process communication through this two-layer nested combination architecture, and the access rights to the allocated communication memory are transferred through the SPMP register during the communication process, so that at the same time, only one requesting process or responding process has access to the communication memory, avoiding unnecessary and malicious modifications to shared memory, improving the security of inter-process communication, meeting the security requirements of communication between different processes, and ensuring the orderliness of communication.
[0031] Optionally, the operation of refreshing the configuration information in the privileged mode physical memory protection register to the first configuration information may specifically include: S21. Allocate a privileged mode physical memory protection register for the communication memory as a communication register, where the communication register includes an authority register and an address register.
[0032] S22: Refresh the first configuration information into the permission register, and refresh the memory size and starting address of the communication memory into the address register.
[0033] Specifically, SPMP registers typically include two types of registers: one type is used to configure the protected memory address, which may include the memory size and starting address of the protected memory, and can be recorded as an address register. The other type is used to configure a process's access rights to the protected memory, and can be recorded as a permission register.
[0034] Accordingly, the embodiment of the present invention can select a group of idle SPMP registers including permission registers and address registers according to all SPMP registers provided by the RISC-V architecture and allocate them to the communication memory as communication registers. Furthermore, the embodiment of the present invention can refresh the first configuration information into the permission register, and refresh the memory size and starting address of the communication memory into the address register. Specifically, the permission register can contain 8 data bits, and different data bits can represent different meanings. For example, the lower 2 bits can be used to represent the process ID controlled, and the upper 3 bits can be used to represent the access rights (for example: 000 represents that the access right is inaccessible, and 111 represents that the access right is allowed). Alternatively, the lower 3 bits can also be used to represent the access rights, and the meaning of each data bit in the above-mentioned SPMP register can also be set according to actual needs, and the embodiment of the present invention does not limit this.
[0035] In an embodiment of the present invention, a privileged mode physical memory protection register is allocated to the communication memory as a communication register, the communication register including a permission register and an address register; the first configuration information is refreshed into the permission register, and the memory size and starting address of the communication memory are refreshed into the address register. In this way, the access rights of a requesting process to the communication memory can be configured by writing the first configuration information and the memory size and starting address of the communication memory into the SPMP register.
[0036] Optionally, after the above-mentioned operation of allocating physical memory for the requesting process in the trusted execution environment constructed based on physical memory protection as the communication memory, the embodiment of the present invention may further include: S31. Send mapping instructions to the requesting process and the responding process respectively, so that the requesting process and the responding process perform memory mapping on the communication memory, so as to map the communication memory into a virtual memory based on a page table.
[0037] Specifically, after obtaining the communication memory, embodiments of the present invention can send mapping instructions to the requesting process and the responding process, enabling them to map the communication memory to virtual memory using a page table structure based on their association. The page table is a special data structure used to store the mapping relationship between virtual memory and physical memory. Specifically, since a process actually accesses the corresponding physical memory by accessing virtual memory, and the communication memory is physical memory, embodiments of the present invention can enable the requesting process and the responding process to memory-map the communication memory, achieving address translation through the page table. Specifically, this memory mapping operation can be implemented using memory mapping instructions (e.g., mmap instructions). By decoupling application memory access permissions from page table configuration permissions, memory access operations must simultaneously pass page table checks, PMP checks, and SPMP checks, effectively reducing the risk of page table attacks and providing higher security. Furthermore, the present invention transfers shared memory ownership by configuring the SPMP register on the monitoring end, resulting in higher efficiency than the shared memory remapping methods employed in related technologies.
[0038] In an embodiment of the present invention, the requesting process and the responding process may map the communication memory to the virtual memory based on the page table to implement address translation operations, thereby facilitating the requesting process and the responding process to access the communication memory.
[0039] It should be noted that most current trusted execution environment technologies still rely solely on page tables to restrict memory access. However, since the page tables themselves reside in memory, it is impossible to decouple the restrictions in the page tables from memory access permissions, posing a risk of attack. However, by introducing the SPMP register, the embodiments of the present invention separate memory access permissions. Specifically, the page table is responsible for address translation, while the monitoring end controls process memory access permissions through the SPMP register. Using the SPMP register, page table control is decoupled from memory access permissions, further improving the security of process communications and effectively mitigating attacks against page tables in existing trusted execution environment technologies.
[0040] Optionally, the embodiment of the present invention may further include: S41. In response to receiving a security isolation request from any process, determine a target process indicated by the security isolation request.
[0041] S42: Use the pre-allocated privileged mode physical memory protection register as the running register, and divide the physical memory for the target process in the trusted execution environment constructed based on the physical memory protection as the running memory.
[0042] S43: Write the address information and permission information of the running memory into the running register context, and copy the application corresponding to the target process to the running memory.
[0043] The security isolation request can be sent by any process, including a process with higher security requirements. The security isolation request is used to request execution in a secure environment. Furthermore, the security isolation request can carry the process identifier of the process sending the request, so that embodiments of the present invention can determine the target process indicated by the security isolation request based on the process identifier.
[0044] Furthermore, an embodiment of the present invention can pre-allocate an SPMP register as a running register, allocate physical memory for the target process as running memory, and write the address information and permission information of the running memory into the running register, so that the SPMP register is associated with the physical memory. The application (code) corresponding to the target process is copied to the running memory. The address information of the running memory includes the memory size and starting address of the running memory, and the permission information is used to indicate that other processes are not allowed to access the running memory, thereby achieving secure isolation of the target process through the SPMP register. Of course, other access permissions can also be pre-set according to isolation requirements, and the embodiment of the present invention does not limit this.
[0045] Furthermore, through the above operations, the embodiment of the present invention can nest and divide the trusted execution environment isolated by the PMP using the SPMP registers, thereby realizing a two-layer nested combination architecture of PMP and SPMP. Accordingly, the process running in the running memory can be called an enclave.
[0046] In response to receiving a security isolation request from any process, an embodiment of the present invention determines the target process indicated by the security isolation request; uses pre-allocated privileged mode physical memory protection registers as runtime registers; and, within a trusted execution environment built based on physical memory protection, allocates physical memory for the target process as runtime memory; writes the address information and permission information of the runtime memory into the runtime register context, and copies the application corresponding to the target process to the runtime memory. In this way, the dual-layer nested combination architecture of PMP and SPMP can provide the ability to create large-scale secure enclaves, further adapting to requirements such as confidential computing in cloud scenarios.
[0047] Optionally, the embodiment of the present invention may further include: During the running of any target process, in response to the running request of any other target process, the address information and permission information of the running memory corresponding to the other target process are written into the running register; wherein the other target process is a target process different from the target process.
[0048] The aforementioned other target processes refer to target processes that are isolated and protected, but are different from the target process. Specifically, after the above steps S41-S43, all processes that meet the security isolation requirements have corresponding running memory. On this basis, when switching between processes running in the trusted execution environment, secure switching of processes can be achieved by switching the SPMP register context.
[0049] Specifically, only when the address information and permission information of the running memory corresponding to any target process are written into the running register can the target process be run in secure isolation in the running memory. Therefore, during the running of the target process, the running register stores the address information and permission information of the running memory corresponding to the target process. When a running request from another target process is received, that is, there is a process switching requirement, it is necessary to perform context switching on the running register, that is, write the address information and permission information of the running memory corresponding to the other target process into the running register.
[0050] It should be noted that in related technologies, due to the limitations of hardware architecture and the number of PMP hardware registers defined by the open source instruction set architecture (RISC-V), the trusted execution environment based on the PMP segment isolation mechanism has the problem of insufficient scalability of the number of enclaves, making it difficult to cope with confidential computing cloud scenarios.
[0051] The embodiment of the present invention allocates SPMP registers as running registers, and can use the running registers as the register context of the monitoring end. When the process switches, the context switch can be performed on the SPMP registers. Furthermore, through the above-mentioned architecture and memory management, a single PMP isolated physical memory area can be used to create hundreds of enclave applications, breaking the limitation of the number of PMP registers on the number of enclaves, thereby achieving a highly scalable number of enclaves that can run on a large scale, and can cope with confidential computing cloud scenarios.
[0052] Optionally, physical memory allocation in a trusted execution environment may be implemented through a buddy system, which can manage memory efficiently.
[0053] Optionally, before switching the execution register context corresponding to the target process to the address information of the execution memory corresponding to the other target process, the method further includes: The address information of the running memory corresponding to the target process is written into the memory of the monitoring terminal.
[0054] Specifically, in order to avoid the loss of the address information and permission information of the running memory corresponding to the currently running target process, the address information and permission information of the running memory corresponding to the target process can be stored in the monitoring end memory before the context switch is performed.
[0055] In the embodiment of the present invention, by writing the address information of the running memory corresponding to the target process into the memory of the monitoring terminal, it is possible to achieve context switching while avoiding information loss that affects the subsequent running of the target process.
[0056] It should be noted that the RISC-V architecture security monitor solution in the related art cannot meet the requirements of secure and efficient communication between enclaves in large-scale operation due to the limited number of enclaves. In addition, due to the number of PMPs, the number of enclaves is also limited. In some scenarios where communication is based on copying and encryption, the communication efficiency is low. In addition, some solutions allow multiple enclaves to have ownership of shared memory at the same time, resulting in the inability to meet the security requirements of inter-enclave communication.
[0057] In the embodiment of the present invention, by introducing the SPMP register, when processes use shared memory for communication, the SPMP register can be used to associate with the process, and the configuration of the shared memory permissions can be realized through the SPMP register. By refreshing the configuration information of the SPMP register, the ownership of the shared memory can be transferred, thereby realizing a zero-copy ownership transfer mechanism based on the SPMP extension, which can realize efficient, orderly, controllable and secure access to the shared memory between enclaves.
[0058] At the same time, the related art uses a trusted execution environment system (TEEOS) running in a higher (Superior) mode to use SPMP to create an extensible TEE program, but the embodiment of the present invention does not require the support of TEEOS and can achieve process isolation protection only through PMP and SPMP.
[0059] Among them, the above-mentioned permission configuration can be achieved by configuring page table permissions. The requesting process can have SPMP read and write permissions of shared memory by default. At any time, only one owner has read and write permissions to shared memory. The ownership of shared memory is transferred from one owner to the next owner by executing the process communication method provided by the monitoring end. Under the control of the monitoring end, disorderly and malicious modifications to the shared memory are avoided, ensuring the orderliness and security of communication.
[0060] Optionally, embodiments of the present invention can also configure SPMP registers to convert dynamic memory requested by enclave applications during runtime into secure memory, enabling dynamic expansion of secure memory and more flexible dynamic allocation of secure memory. Furthermore, embodiments of the present invention can utilize the monitoring terminal as a security monitor, making it part of the trusted base within the trusted execution environment. This can be further expanded and modified through formal proofs, ensuring simplicity in software development and design, avoiding redundant code, and providing stronger evidence of its security through formal verification and other methods.
[0061] Figure 2 FIG. 1 is a schematic diagram of the structure of a process communication device according to an embodiment of the present invention, wherein the device is applied to a monitoring terminal included in a process communication system, wherein the process communication system further includes at least two processes, such as Figure 2 As shown, the device 20 may include: A first determining module 201 is configured to, in response to receiving a communication request from any process, determine a requesting process and a responding process indicated by the communication request; A first allocation module 202 is configured to allocate physical memory to the requesting process as communication memory in a trusted execution environment constructed based on physical memory protection, and to refresh configuration information in a privileged mode physical memory protection register to first configuration information, wherein the first configuration information is used to indicate that the access permission of the requesting process to the communication memory is allowed; a refresh module 203 configured to, after the requesting process accesses the communication memory and writes the communication data, refresh the configuration information in the privileged mode physical memory protection register to second configuration information, so that the responding process reads the communication data in the communication memory and writes the response data, wherein the second configuration information is used to indicate that the responding process has permission to access the communication memory; The execution module 204 is configured to re-execute the operation of refreshing the configuration information in the privileged mode physical memory protection register to the first configuration information, so that the requesting process reads the response data in the communication memory.
[0062] Optionally, the refresh module includes: A second allocation submodule is configured to allocate a privileged mode physical memory protection register to the communication memory as a communication register, wherein the communication register includes an authority register and an address register; A refresh submodule is used to refresh the first configuration information into the permission register, and refresh the memory size and starting address of the communication memory into the address register.
[0063] Optionally, the device further includes: The sending module is used to send mapping instructions to the requesting process and the responding process respectively, so that the requesting process and the responding process perform memory mapping on the communication memory, so as to map the communication memory into a virtual memory based on a page table.
[0064] Optionally, the device further includes: A second determining module is configured to, in response to receiving a security isolation request from any process, determine a target process indicated by the security isolation request; a third allocation module, configured to use the pre-allocated privileged mode physical memory protection register as the running register, and to allocate physical memory for the target process in a trusted execution environment constructed based on the physical memory protection as the running memory; The first writing module is used to write the address information and permission information of the running memory into the running register, and copy the application corresponding to the target process to the running memory.
[0065] Optionally, the device further includes: The second writing module is used to write the address information and permission information of the running memory corresponding to any other target process into the running register in response to the running request of any other target process during the running of any target process; wherein, the other target process is a target process different from the target process.
[0066] Optionally, the device further includes: The third writing module is used to write the address information and permission information of the running memory corresponding to the target process into the memory of the monitoring terminal.
[0067] Optionally, the device further includes: A release module is used to release the communication memory and delete the configuration information in the privileged mode physical memory protection register.
[0068] In summary, the process communication device provided by the embodiment of the present invention determines the requesting process and the responding process indicated by the communication request in response to receiving a communication request from any process; allocates physical memory to the requesting process in a trusted execution environment constructed based on physical memory protection as communication memory, and refreshes the configuration information in the privileged mode physical memory protection register to the first configuration information, the first configuration information being used to characterize that the access right of the requesting process to the communication memory is allowed access; after the requesting process accesses the communication memory to write communication data, the configuration information in the privileged mode physical memory protection register is refreshed to the second configuration information, so that the responding process reads the communication data in the communication memory and writes response data, the second configuration information being used to characterize that the access right of the responding process to the communication memory is allowed access; and the operation of refreshing the configuration information in the privileged mode physical memory protection register to the first configuration information is performed again, so that the requesting process reads the response data in the communication memory. In this way, by allocating physical memory to processes that need to communicate with each other in a trusted execution environment, a two-layer nested combination architecture based on PMP and SPMP can be implemented. Physical memory is allocated for process communication through this two-layer nested combination architecture, and the access rights to the allocated communication memory are transferred through the SPMP register during the communication process, so that at the same time, only one requesting process or responding process has access to the communication memory, avoiding unnecessary and malicious modifications to shared memory, improving the security of inter-process communication, meeting the security requirements of communication between different processes, and ensuring the orderliness of communication.
[0069] The embodiment of the present invention further provides an electronic device, such as Figure 3 As shown, it includes a processor 9001, a communication interface 9002, a memory 9003 and a communication bus 9004, wherein the processor 9001, the communication interface 9002, and the memory 9003 communicate with each other through the communication bus 9004. Memory 9003, used for storing computer programs; The communication bus mentioned in the terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0070] The communication interface is used for communication between the above terminal and other devices.
[0071] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0072] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0073] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions that, when executed on a computer, enable the computer to execute the process communication method described in any one of the above embodiments.
[0074] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the process communication method described in any one of the above embodiments.
[0075] In the above embodiments, all or part of the embodiments can be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be magnetic media (e.g., floppy disk, hard disk, tape), optical media (e.g., DVD), or semiconductor media (e.g., solid-state disk (SSD)).
[0076] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0077] It should be noted that the various data-related processes in the embodiments of the present application are all carried out in compliance with the corresponding data protection laws and policies of the country where they are located, and with the authorization given by the owner of the corresponding device.
[0078] Each embodiment in this specification is described in a related manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiment is generally similar to the method embodiment, so the description is relatively simple. For related parts, refer to the description of the method embodiment.
[0079] The above description is only a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention are included in the scope of protection of the present invention.
Claims
1. A process communication method, It is characterized in that The method is applied to a monitoring end included in a process communication system, wherein the process communication system also includes at least two processes, and the method includes: In response to receiving a communication request from any process, determining a requesting process and a responding process indicated by the communication request; In a trusted execution environment built based on physical memory protection, physical memory is allocated to the requesting process as communication memory, and configuration information in a privileged mode physical memory protection register is refreshed to first configuration information, where the first configuration information is used to indicate that the access right of the requesting process to the communication memory is allowed access; After the requesting process accesses the communication memory to write the communication data, the configuration information in the privileged mode physical memory protection register is refreshed to the second configuration information, so that the responding process reads the communication data in the communication memory and writes the response data, wherein the second configuration information is used to indicate that the access right of the responding process to the communication memory is allowed to access; The operation of refreshing the configuration information in the privileged mode physical memory protection register to the first configuration information is performed again, so that the requesting process reads the response data in the communication memory.
2. The method according to claim 1, It is characterized in that The step of refreshing the configuration information in the privileged mode physical memory protection register to the first configuration information includes: Allocating a privileged mode physical memory protection register for the communication memory as a communication register, wherein the communication register includes an authority register and an address register; The first configuration information is refreshed into the permission register, and the memory size and the starting address of the communication memory are refreshed into the address register.
3. The method according to claim 1, It is characterized in that After allocating physical memory as communication memory to the requesting process in the trusted execution environment constructed based on physical memory protection, the method further includes: A mapping instruction is sent to the requesting process and the responding process respectively, so that the requesting process and the responding process perform memory mapping on the communication memory, so as to map the communication memory into a virtual memory based on a page table.
4. The method according to claim 1, It is characterized in that The method further comprises: In response to receiving a security isolation request from any process, determining a target process indicated by the security isolation request; Using a pre-allocated privileged mode physical memory protection register as a running register, and dividing physical memory for the target process in a trusted execution environment built based on physical memory protection as a running memory; The address information and permission information of the running memory are written into the running register, and the application corresponding to the target process is copied to the running memory.
5. The method according to claim 4, It is characterized in that The method further comprises: During the running of any target process, in response to the running request of any other target process, the address information and permission information of the running memory corresponding to the other target process are written into the running register; wherein the other target process is a target process different from the target process.
6. The method according to claim 5, It is characterized in that Before writing the address information of the running memory corresponding to the other target process into the running register corresponding to the target process, the method further includes: The address information and permission information of the running memory corresponding to the target process are written into the memory of the monitoring terminal.
7. The method according to any one of claims 1 to 6, It is characterized in that After the request process reads the response data in the communication memory, the method further includes: The communication memory is released, and the configuration information in the privileged mode physical memory protection register is deleted.
8. A process communication device, It is characterized in that The device is applied to a monitoring end included in a process communication system, wherein the process communication system also includes at least two processes, and the device includes: A first determining module, configured to, in response to receiving a communication request from any process, determine a requesting process and a responding process indicated by the communication request; A first allocation module is used to allocate physical memory to the requesting process in a trusted execution environment built based on physical memory protection as communication memory, and refresh the configuration information in the privileged mode physical memory protection register to first configuration information, wherein the first configuration information is used to indicate that the access right of the requesting process to the communication memory is allowed access; A refresh module, configured to refresh the configuration information in the privileged mode physical memory protection register to second configuration information after the requesting process accesses the communication memory to write the communication data, so that the responding process reads the communication data in the communication memory and writes the response data, wherein the second configuration information is used to indicate that the access right of the responding process to the communication memory is allowed to access; The execution module is used to re-execute the operation of refreshing the configuration information in the privileged mode physical memory protection register to the first configuration information, so that the request process reads the response data in the communication memory.
9. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-7 when executing a program stored in a memory.
10. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Memory management method and system, security processing device and data processing device
CN112256396A
Physical memory protection method and system based on RISC-V and related equipment
CN114741740A
Method and device for first operating system to access resources of second operating system
WO2021098244A1
Communication method in computer system, and related product
WO2023103697A1
